Cloud · Gateway & Routing · DWG NO. 035

Gateway Aggregation

Let one API call fan out to several backend services and combine their results, so the client makes one round trip instead of several.

TypeGateway/Routing
ScopeClient-facing entry point
ComplexityMedium
Common inMobile backends, BFF layers, microservice front doors

A mobile client making five sequential calls over a slow connection

A product page might need data from a catalog service, a pricing service, a reviews service, and an inventory service. If the mobile app calls all four directly, that's four round trips over a possibly slow or high-latency connection, each with its own failure mode to handle client-side.

One gateway call, fanned out server-side

The client makes a single call to a gateway. The gateway calls the necessary backend services — in parallel where possible — and combines their responses into one payload shaped for that client, before returning it in a single response.

Mobile App1 callGatewayCatalogPricingReviews

A gateway fanning out to three backend services in parallel

The client issues one call to `getProductPage`; the gateway handles calling three services concurrently and assembles one combined result.

gateway-aggregation.js
const catalogService = async (id) => ({ id, name: "Wireless Mouse" });
const pricingService = async (id) => ({ id, price: 29.99 });
const reviewsService = async (id) => ({ id, rating: 4.5, count: 128 });

async function getProductPage(id) {
  const [catalog, pricing, reviews] = await Promise.all([
    catalogService(id),
    pricingService(id),
    reviewsService(id),
  ]);

  return {
    id,
    name: catalog.name,
    price: pricing.price,
    rating: reviews.rating,
    reviewCount: reviews.count,
  };
}

// The client makes exactly one call and gets back one combined shape.
const page = await getProductPage("sku-101");
console.log(page);

Trade-offs