title: Microservice API Gateway Pattern - question about two design options
body: <p>In the standard micro service API gateway pattern (if you research any major site discussing this pattern ) you will see the same api gateway pattern in which  one or more API Gateway(s) sit in front of one or more micro services and communicates with them via HTTP/REST or gRPC.</p>
  <p>Here is one sample image of this api gateway design pattern and the source for it below.</p>
  <p><a href="https://i.stack.imgur.com/fnGQW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fnGQW.png" alt="Api gateway pattern" /></a></p>
  <p>image reference: <a href="https://devblogs.microsoft.com/cesardelatorre/designing-and-implementing-api-gateways-with-ocelot-in-a-microservices-and-container-based-architecture/" rel="nofollow noreferrer">https://devblogs.microsoft.com/cesardelatorre/designing-and-implementing-api-gateways-with-ocelot-in-a-microservices-and-container-based-architecture/</a></p>
  <p>This design concept is very heavily documented online and so i wont add anymore detail to that design concept here.</p>
  <p>We are looking to implement an API Gateway pattern for our micro service architecture.</p>
  <p>The above design pattern is for certain an option we have reviewed but  we also considered a different option in which the gateway would be fully decoupled from all micro services by sticking a publish/subscribe event bus in the middle of the architecture between the API Gateway and the micro services themselves.</p>
  <p>In this design concept, the gateway would publish messages directly onto the event bus and the micro services would subscribe and process these messages. They would communicate back to the bus and the API gateway would subscribe to those messages and (in theory) then return to the calling client over https.</p>
  <p>The gateway and micro services would not speak to each other or be coupled to each other in any way.</p>
  <p><a href="https://i.stack.imgur.com/7g5AJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7g5AJ.png" alt="enter image description here" /></a></p>
  <p>I have not seen an API gateway pattern that speaks directly to an event bus like this and I am guessing that there are reasons why and that we are not considering all of them.</p>
  <p>I am guessing that there may be two immediate reasons that I can think of:</p>
  <ol>
  <li><p>the http response to the client would have to somehow wait on the subscribe event so that it could return data to the client. I am not quite sure how this would work without messing with some code.</p>
  </li>
  <li><p>The API gateway would seemingly have to subscribe to a 'plethora' of events as it communicates to the event bus and the event bus is being monitored by various micro services.   As the number of microservices grows, the number of events that the gateway would need to subscribe to would also grow and it feels like this code could grow quite large in the gateway.</p>
  </li>
  </ol>
  <p>Could anyone with API gateway pattern experience speak to this concept of communicating directly to an eventbus instead of to the microservices directly?</p>