10

I am trying to wrap my head around the differences between an API gateway and the aggregator pattern for microservices.

At the moment From my understanding the aggregator pattern functions by collecting pieces of data from various microservices and returns an aggregate for processing.

Now the API gateway is the single entry point that aggregates the calls to the individual microservices. While this may sound very similar to the Aggregator Pattern, there are some distinct features. Most importantly, this new service does not store data but instead becomes responsible for API composition, request routing, and new features such as authentication

I would really like to understand if my reasoning is correct here.

Thank you in advance!

Mahir Hiro
  • 135
  • 1
  • 7

2 Answers2

8

Yes, your understanding is correct. I would add a few ideas:

  • The API Gateway usually is entry-point of the system, while an aggregator microservice can be somewhere in the middle-layer.
  • The API Gateway may store partial responses from other microservices, while it waits for other ones to respond (similarly to an aggregator)
  • There is also a pattern which mixes them, known as a gateway aggregation pattern
Cosmin Ioniță
  • 3,598
  • 4
  • 23
  • 48
1

Though this seems very similar having a aggregator service vs API Gateway acting as a aggergator.

Think about much bigger ecosystem, where API Gateway would genrally be 1, but we can have number of aggregator services.

Aggregator service will generally lie in middle layer and can be built using specific patterns, these can be Parallel, Chaining or Branching.

Taking example of ecommerce application, we can have below aggregators and more.

Customer Dashboard Aggrgator (Recommeneded products, past orders, current active order etc)

Cart Aggregator (Shipping Service, Inventory Service, Discount Service)

Order History Aggregator

Customer Information Aggregator (Personal Information, Address)

Ankur Singhal
  • 26,012
  • 16
  • 82
  • 116