frameworkEngineering & architecture

API Gateway

A managed entry boundary that routes API traffic and applies shared policies before requests reach backend services.

Download Markdown (.md)

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]

Application boundary One client-facing boundary routes to multiple backend capabilities
  1. API consumersClient requests
  2. API gatewayPolicy, routing, composition
  3. 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

  1. Define the client-facing routes, protocols, ownership, and compatibility contract.
  2. Authenticate callers and apply authorization, quota, and request-validation policies at suitable layers.
  3. Route each accepted request to a healthy backend or compose a bounded response.
  4. Transform protocols or payloads only where the benefit exceeds added coupling.
  5. Propagate correlation, identity, deadlines, and errors without hiding backend behavior.
  6. Monitor gateway latency, rejection reasons, route health, policy changes, and availability.

05A practical example

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

  1. What Is Amazon API Gateway?Amazon Web Services · Official technical documentationWhat Is Amazon API Gateway?
  2. Gateway Routing PatternMicrosoft Learn · Institutional architecture guideGateway Routing Pattern
View saved topics

Start typing to search titles, definitions, categories, and frameworks.