Without a gateway, every client knows the addresses of all the services, and each service checks tokens and enforces rate limits on its own. An API gateway brings these tasks together in one place: clients call a single address, and the gateway decides which service to pass each request to and what to check first. It also hides how the system is split into services: services can change without touching the clients.
What an API gateway does
- Routing: uses the path, method or headers to decide which service handles a request; some requests pass through unchanged, others are split across several services.
- Authentication and access control: checks tokens and keys once, at the entrance.
- Traffic management: rate limits and quotas, protecting services from overload.
- Aggregation: combines responses from several services into one, so the client makes a single request instead of several.
- Protocol translation: the outside sees web-friendly HTTPS and JSON, while inside the services use whatever suits them, such as gRPC.
- Observability: logging and metrics for every request; staged rollouts, such as canary releases.
Example
An online shop built as microservices — orders, basket, payments — puts a gateway at the entrance. The app always calls shop.example/api/…; the gateway checks the JWT, routes /orders to the orders service and /cart to the basket service, and assembles the product page from the responses of three services. It allows anonymous visitors ten requests per minute and authorised customers a thousand. The services know nothing about authentication or each other’s addresses.
The price to pay
A gateway is one more component to develop, deploy and monitor, plus an extra network hop on the path of every request. For most applications the cost of the hop is imperceptible, and large gateways handle hundreds of thousands of concurrent calls. Without a gateway, these same tasks would spread across all the services and clients.
Sources
the term is written from these pages- AWS — What is Amazon API Gateway?docs.aws.amazon.com/apigateway/latest/developerguide/welcome.html(opens in a new tab)
- microservices.io — Pattern: API Gateway / Backends for Frontendsmicroservices.io/patterns/apigateway.html(opens in a new tab)
- Kong Gateway — What is an API gatewaydeveloper.konghq.com/gateway/(opens in a new tab)
Verified 8 Nov