What Is an API Gateway? Connecting Multiple Services Through One Entry Point
An API gateway is an entry layer between clients and backend services. It commonly routes requests received at one public address to the appropriate service and applies shared handling such as authentication, rate limiting, and observability. It can also combine responses from multiple services, but putting all composition logic in the gateway can create a bottleneck and widen the impact of failures. This article explains the pattern for microservices and HTTP APIs and how to decide whether to use it.
An API gateway is an entry layer between clients and backend services. It commonly routes requests received at one public address to the appropriate service and applies shared handling such as authentication, rate limiting, and observability. It can also combine responses from multiple services, but putting all composition logic in the gateway can create a bottleneck and widen the impact of failures. This article explains the pattern for microservices and HTTP APIs and how to decide whether to use it.
Where does an API gateway sit in the request flow?
The basic flow is client → gateway → backend service. A gateway behaves like a reverse proxy and can route to internal services based on request information such as path, host, or headers. This reduces how much clients need to know about service-specific addresses and deployments. Backend services can also be restricted from direct external access, but a gateway alone does not complete security. Design authorization checks in the services and network policies as well. (Microsoft API gateways overview, Gateway Routing pattern)
Its main responsibilities fall into three groups:
**Routing:** Forward a client request to one or more services or service instances. Client paths can remain stable even when backend services are replaced or split.
**Shared policy handling:** Centralize recurring concerns across services, such as TLS termination, authentication integration, IP allow or block lists, throttling, logging, monitoring, and caching. Available features vary by product and configuration.
**Request aggregation:** When one client operation needs multiple backend calls, combine their results into one response. This can reduce client round trips, but adds responsibility for failure handling and data consistency to the gateway.
When should aggregation live in the gateway or a dedicated service?
Suppose an order-summary screen needs order, shipping, and customer information. If the client calls all three services directly, it must manage multiple addresses and error flows. With gateway aggregation, the gateway makes the three calls, combines the responses, and returns one result. This can reduce client round trips on a slow network. (Gateway Aggregation pattern)
If aggregation grows beyond a simple read composition and needs complex domain rules, long-running orchestration, or distinct resource requirements, it may be easier to manage a dedicated backend service and let the gateway route to it. Define whether a failure in one backend call fails the entire operation or produces a partial response. Partial responses can help a screen where missing data is acceptable, but they can also make an incomplete result look successful.
| Situation | Aggregate in the gateway | Dedicated service behind the gateway |
|---|---|---|
| Combine two or three simple reads with a small result | May fit | May add unnecessary operational structure |
| Includes domain rules or multi-step writes | Policy code can become complex | Easier to separate ownership and testing boundaries |
| Needs independent scaling, long processing, or complex recovery | Can make the gateway's routing role heavy | Easier to manage separate resources and release cycles |
This comparison is an architecture decision aid, not a performance guarantee. Measure actual latency, response size, and failure rates under representative load.
What costs and failure risks should you check?
A gateway provides a convenient shared entry point, but it can also become a dependency for every request. Insufficient capacity or an outage can affect multiple services at once. Design multiple instances, deployment that meets availability goals, timeouts and circuit breakers, and load tests. For aggregation, define how each backend's latency affects the final response and how partial failures are handled. Propagate a correlation ID to trace a client request together with its internal calls, and monitor request latency, errors, and response size. (Gateway Aggregation considerations)
Even when common security policies live at the gateway, review the trust boundary for internal services. Confirm that clients cannot bypass the gateway to reach a backend, and validate forwarded user identity or headers before a service trusts them. Managing policy settings, certificates, and routing rules as code or reviewable configuration makes changes easier to track.
Is it the same as a reverse proxy or load balancer?
The functions can overlap, but the terms do not mean exactly the same thing. A reverse proxy is a broad pattern for forwarding requests in front of servers; a load balancer focuses on distributing traffic across instances. An API gateway may include these functions and add API management capabilities such as API-path routing, authentication integration, throttling, request and response transformation, and aggregation. Check product documentation and configuration to see whether load balancing is included and where authentication and policy features apply. Microsoft documents a product-specific limitation: Azure API Management does not perform load balancing itself. (Microsoft API gateway technology choices)
Checklist before adopting a gateway
Are the service addresses and routing needs that should be hidden or simplified for clients clear?
Does the product actually support the shared policies you need, and do they work with service-side security?
Have you distinguished lightweight read composition from domain logic that belongs in a dedicated service?
Have you planned redundancy and load tests so a gateway outage or capacity limit does not take down several services at once?
Are timeouts, retries, circuit breakers, partial-response rules, and error responses defined?
Do you have correlation IDs and metrics for latency, errors, and response size that cover internal calls?
Is direct access to backends restricted, and are changes to routing, authentication, and certificates managed in a reviewable way?