Skip to main content

Gateway Aggregation

Gateway Aggregation combines multiple backend calls into one at the gateway, so chatty clients make a single request. It reduces round-trips on slow networks and keeps backend services fine-grained.

Type
Architectural
When to Use
Chatty Clients, High Latency Networks, Reduce Round Trips, Mobile Clients

Gateway Aggregation is a cloud design pattern in which a gateway receives one client request, dispatches several requests to backend services, and returns a single combined response. It reduces the chattiness between client and backend, which matters most over high-latency or metered networks such as mobile.

How It Works

The gateway exposes a coarse-grained endpoint. When a client calls it, the gateway decomposes the request into the individual backend calls required, issues them (ideally in parallel), and assembles the results into one response. The client experiences a single round-trip even though many services contributed. The gateway handles timeouts, partial failures, and response shaping on the client's behalf.

This is the Aggregator pattern realized at the gateway tier, frequently implemented in an API gateway or a backend-for-frontend.

The aggregated endpoint is usually coarse-grained and purpose-built for a screen or use case, which keeps the contract stable even as backend services are refactored. The gateway should issue the underlying calls concurrently, enforce a deadline, and return partial results with clear markers when a non-essential dependency is unavailable, so the client can still render the bulk of the view.

When to Use It

Use gateway aggregation when clients otherwise make many small requests to render a single view, when the network between client and backend is slow or expensive, or when you want to keep backend services fine-grained without burdening clients. Mobile and remote clients benefit the most.

Avoid pushing heavy business logic into the gateway; if aggregation grows complex, a dedicated aggregation service or BFF is cleaner.

It also helps when a client would otherwise need to orchestrate calls in a specific order, since the gateway can encapsulate that sequencing and expose a single simple operation instead.

Trade-offs

Aggregation cuts round-trips and simplifies clients, but the gateway becomes coupled to backend shapes and is bounded by its slowest dependency, so it must apply timeouts and graceful degradation. Too much aggregation logic can bloat the gateway into a single point of failure and a deployment bottleneck. Keep aggregations focused. Because the aggregated endpoint is coupled to a particular client view, teams often pair this pattern with a backend-for-frontend so each client gets aggregations shaped for it without bloating a shared gateway.

Related Patterns

Gateway Aggregation is one of the three classic gateway responsibilities alongside Gateway Routing and Gateway Offloading. It is the Aggregator pattern at the edge and often lives inside an API Gateway or Backend for Frontend. The Aggregator and Scatter-Gather patterns describe the same fan-out-and-merge idea applied outside the gateway tier.

Example

A mobile home screen needs profile, notifications, and recommendations, each owned by a different service. Over a 4G connection, three separate calls are slow. The app instead calls /home on the gateway. The gateway fans out the three requests in parallel, merges them, and returns one payload in a single round-trip, noticeably improving perceived load time on poor connections.