2

I am trying to build a system which involves a client which will talk to a few microservices. I got to the point where I realize I don't want the client to communicate directly with all the microservices so an API Gateway sounds like the right choice.

The issue is with the API Composition, I came across 2 options that I am trying to understand.

  1. The API Gateway aggregator is quite understandable as it will query the microservices on its own and combine the result to return to the client. From what I understand it means that it has to have some of the logic of all microservices, is that correct? If so, is it a good approach?

  2. The API Gateway with the Aggregator pattern (separately). If I implement these 2 I will get something like this: API And Aggregator

From what I see it appears that the API Gateway will no longer do any routing since it has a bottleneck to that aggregator (which will do the requests to other services on its own). So I will get only Auth, Cache and load balancing from the API Gateway but the aggregator will do the routing as if he is the gateway?

Gilad Dahan
  • 508
  • 5
  • 19
  • Is there any reason the aggregator couldn't route its requests through the gateway to leverage the gateway for routing? – Levi Ramsey Jan 19 '22 at 12:58
  • Not sure I follow, you mean to have the aggregator in front of the API gateway? I haven't seen it used that way. If so, do you have any info\article about this kind of behavior that you can share? – Gilad Dahan Jan 19 '22 at 13:05
  • The aggregator still sits behind the gateway. – Levi Ramsey Jan 19 '22 at 15:11
  • Can you please explain the solution you are talking about in more details? Because I am not sure I understand. I am fairly new to this and have seen hundreds of articles\videos but still something is missing – Gilad Dahan Jan 19 '22 at 15:22
  • 1
    Requests from outside go through the gateway to the aggregator service (e.g. `AddItem`). Aggregator service sends `GetProduct` request through gateway to product service etc (i.e. set up the gateway so that `AddItem` goes to the aggregator, `GetProduct` goes to product service; the gateway should also be able to be set up so that external requestors can't `GetProduct`). – Levi Ramsey Jan 20 '22 at 15:41
  • Doesn’t it make the gateway and aggregator extremely coupled with one another? The aggregator will be dependent upon the gateway – Gilad Dahan Jan 20 '22 at 18:24

0 Answers0