Problem Statement

A microservice based application can have multiple services, each performing a unique individual task. A client to the application may require combinations of data obtained from each of those microservices. Microservices usually provide fine-grained APIs, which means that the client would need to interact with every individual microservice of interest.

The Aggregator Pattern attempts to solve a similar problem as the API Gateway Pattern.

The Aggregator Pattern

The Aggregator is a microservice by itself. It provides a unified API to a client obtain data from various microservices. Unlike the API Gateway pattern, the Aggregator will not be an entry point to the system.

This is a composite service that is used when we need to apply a set of rules while preparing the result data created from the outputs of multiple microservices.

The Aggregator pattern sends requests to multiple services for data, and then aggregates the data for the requestor.

Usage of the Aggregator Pattern

The Aggregator is efficient when:

  • Used as a collection point for data from microservices, and not as a switch or router;
  • When the collected data must be processed according to certain rules
  • When the transaction rate is low
  • When the risk due to the Fan-out Antipattern is low (ie. when multiple services fail leading to a potential slowing down or disruption of services)
  • When data provider services are asynchronous

Advantages of the Aggregator Pattern

  • Reduces the communication overhead between a client and the services from whom it requires data
  • Architecturally, allows for simple endpoint consolidation of discrete functionality.

Disadvantages of the Aggregator Pattern

Some issues with the usage of this pattern may be:

  • Updates to the implementation due to new service additions may require us to redesign the code.
  • Increased risk of latency or failure when one or more of the data provider microservices (or their dependencies) fail
  • Troubleshooting may be laborious

Contextual Example

An example can be found in [6].

Online Code Examples

[Example 1]


[1] DZone on the Aggregator Pattern:

[2] API Gateway Pattern:

[3] Aggregator vs. API Gateway:

[4] Aggregator on the AKF page:

[5] Fan-out Antipattern :

[6] Gateway aggregation :