API Gateway
A managed entry boundary that routes API traffic and applies shared policies before requests reach backend services.
Download Markdown (.md)Soroush’s Product Wiki · https://wiki.soroush.uk/topic/api-gateway/
01What it means
An API gateway is a component positioned between API consumers and backend services. It receives requests, selects a destination, and may handle cross-cutting concerns such as authentication enforcement, rate limits, protocol translation, response aggregation, logging, and traffic policy. It is an application-facing boundary, whereas a load balancer primarily distributes traffic among eligible targets.[1][2]
- API consumersClient requests
- API gatewayPolicy, routing, composition
- Backend servicesBusiness capabilities
Response, error, and correlation context
Gateway policy does not remove backend behavior or failure.
02Why it matters
A gateway can give clients one stable interface while internal services change and can enforce important policies consistently. It also concentrates latency, configuration, security, and availability risk, so teams need clear ownership and restraint about which logic belongs there.
03When to use it
Use an API gateway when multiple services need a shared external boundary, consistent traffic policy, or client-oriented routing and composition. A direct service endpoint or simple load balancer may be sufficient for a small system with one backend and few cross-cutting policies.
04How it works
- Define the client-facing routes, protocols, ownership, and compatibility contract.
- Authenticate callers and apply authorization, quota, and request-validation policies at suitable layers.
- Route each accepted request to a healthy backend or compose a bounded response.
- Transform protocols or payloads only where the benefit exceeds added coupling.
- Propagate correlation, identity, deadlines, and errors without hiding backend behavior.
- Monitor gateway latency, rejection reasons, route health, policy changes, and availability.
05A practical example
A marketplace exposes one mobile API boundary for catalog, accounts, and orders. The gateway verifies tokens, applies per-client limits, and routes requests to separately deployed services, while business pricing logic remains inside the owning services.
06Where it breaks
A gateway can become a bottleneck, single failure domain, or central team queue. Excessive response composition and business logic couple releases and make debugging harder. It does not remove the need for service-level authorization, resilience, or contract governance.
Common mistakes
- Treating the gateway as the only authorization layer for sensitive backend actions.
- Moving changing business logic into shared routing configuration.
- Confusing API management and composition needs with simple load distribution.
- Adding a gateway without redundancy, policy testing, or end-to-end tracing.
07Sources
- What Is Amazon API Gateway?Amazon Web Services · Official technical documentationWhat Is Amazon API Gateway?
- Gateway Routing PatternMicrosoft Learn · Institutional architecture guideGateway Routing Pattern