Monday, January 8, 2024

API Gateway Pattern

 Problem

When an application is broken down to smaller microservices, there are a few concerns that need to be addressed:

  1. How to call multiple microservices abstracting producer information.
  2. On different channels (like desktop, mobile, and tablets), apps need different data to respond for the same backend service, as the UI might be different.
  3. Different consumers might need a different format of the responses from reusable microservices. Who will do the data transformation or field manipulation?
  4. How to handle different type of Protocols some of which might not be supported by producer microservice.

 Solution

An API Gateway helps to address many concerns raised by microservice implementation, not limited to the ones above.

  1. An API Gateway is the single point of entry for any microservice call.
  2. It can work as a proxy service to route a request to the concerned microservice, abstracting the producer details.
  3. It can fan out a request to multiple services and aggregate the results to send back to the consumer.
  4. One-size-fits-all APIs cannot solve all the consumer's requirements; this solution can create a fine-grained API for each specific type of client.
  5. It can also convert the protocol request (e.g. AMQP) to another protocol (e.g. HTTP) and vice versa so that the producer and consumer can handle it.
  6. It can also offload the authentication/authorization responsibility of the microservice.

 

 

No comments:

Post a Comment