Common Amazon API Gateway Patterns for microservice architecture:
Amit Kumar
AWS Solution Architect | 3X AWS | Terraform | Kubernetes | EKS | DXC Diamond Award Winner
API Gateway:
API Gateway is a fully managed service that allows to create RESTful and WebSocket APIs at any scale. API Gateway handles all the tasks involved in accepting and processing up to hundreds of thousands of concurrent API calls, including traffic management, CORS, authorization, throttling, monitoring, and version management.
It provides end users with the lowest possible latency for API requests and responses by taking advantage of AWS global network of edge locations using CloudFront.
API Gateway Pattern:
The API gateway pattern is recommended if you want to design and build a microservices-based applications with multiple client applications. API gateway provides a single endpoint or URL for the client applications, and it internally maps the requests to internal microservices.
This can be achieved in multiple ways:
Use Case:
A customer makes a payment in a system that consist of 4 microservices deployed as Lambda functions ("Customer","Communication","Payment" and "Sales").
Payment microservice is the overall system that the customer uses to make payment.
Unified API gateway:
In the following illustration, each microservice is deployed as a Lambda function but all microservices are connected by the same API gateway.
领英推荐
Main API Gateway with gateway per service:
In the following illustration, each microservice has its own API gateway. The "Payments" microservice calls out individual systems and implements the API gateway pattern.
Load Balancer in front of multiple API gateways:
This solution allows you also to have other targets along with API gateway, like EC2, Load Balancers, etc.
Challenges:
Summary:
This article explored three approaches for using an API Gateway in a microservices architecture:
Each method has its advantages and drawbacks. The unified API Gateway is the most cost-effective, while the Load Balancer setup offers the highest level of robustness.