
- Microservices Design Patterns Tutorial
- Microservices Design Patterns - Home
- Microservices Design Patterns - Overview
- Decomposition Design Patterns
- Decompose by Business Capability
- Decompose by Subdomain
- Decompose by Strangler
- Integration Design Patterns
- API Gateway
- Aggregator
- Proxy
- Client Side UI Composition
- Chain Of Responsibilities
- Branch
- Database Design Patterns
- Database per Service
- Shared Database per Service
- Command Query Responsibility Segregator
- Saga
- Aysynchronous Messaging
- Event Sourcing
- Observability Design Patterns
- Log Aggregation
- Performance Metrics
- Distributed Tracing
- Health Check
- Cross Cutting Concern Design Patterns
- External Configuration
- Service Discovery
- Circuit Breaker
- Blue Green Deployment
- Useful Resources
- Quick Guide
- Useful Resources
- Discussion
Microservices Design Patterns - API Gateway
Problem Statement
Microservice architecture structures an application as a set of loosely coupled microservices and each service can be developed independently in agile manner to enable continous delivery/deployment. When a large, complex application is to be built using microservice architecture, microservices can use different protocols. For example, some microservices are using REST and some are following AMQP. Now problem is how to allow clients to access each microservice seemlessly without worrying about protocols and other intricacies.
Solution
We can define an API Gateway which will acts as single entry point for all type of clients. Following are the other benefits of API Gateway −
Simple Proxy − API Gateway can acts as simple proxy to some requests to redirects them to relevant service.
Multiple Services − API Gateway can redirects call to multiple services.
Client Specific API − API Gateway can provide client specific API as well, like a different API for Desktop version than a Mobile Application.
Protocol Handling − API Gateway handles the communication protocols to each service call internally and clients are concerned only with request/response.
Security and Authentication − API Gateway can implement a security that each request goes to service only after authentication and authorization.
Example
Consider an example of an Online Book Store. API Gateway allows to use the online Book store APIs on multiple devices seemlessly.

Advantages
Client Insulation − Clients are insulated from knowing the location of microservices or how to call them.
Multiple Service Calls − API Gateway can handle multiple services and give result as one and thus can reduce the round trips and increase the performance.
Standard Interface − API Gateway provides a standard interface to Clients to get responses from microservices.