Infra Atlas · Decisions

API gateway, proxy or load balancer?

Three things you put in front of services — and they are often layered, not either/or.

Reviewed
The verdict

A load balancer spreads traffic across healthy targets for availability and scale. A reverse proxy is a general-purpose intermediary you fully control — routing, TLS, caching, rewriting. An API gateway is a managed product for publishing and governing APIs — auth, API keys, throttling, transformation, OpenAPI. They are commonly layered (gateway in front of a load balancer in front of services), not a single choice. The deciding factor is how much API-product governance you need.

Head to head
CriterionAPI gatewayReverse proxyLoad balancer
Primary purposePublish and govern APIsA general-purpose request intermediarySpread traffic across healthy targets
OSI layerL7 — HTTP / REST / WebSocketL7L7 (ALB) or L4 (NLB)
Auth & API keysBuilt in — IAM, Cognito, Lambda authorizers, API keysManual configurationALB: OIDC/Cognito. NLB: none
Rate limitingBuilt in — throttling, usage plans, quotasManual (e.g. limit_req)Not provided
TransformationYes — mapping templates and parameter mappingManual header / URI rewritingNone
API-product managementOpenAPI import/export, SDK generation, stagesNoneNone
Who operates itFully managed by AWSYou operate the server / processFully managed by AWS
Typical placementEdge entry point for APIsAny hop you controlIn front of a fleet, often behind a gateway
When to pick which

Reach for an API gateway when

  • You publish APIs and need API keys, usage plans and quotas.
  • You need managed auth and request transformation without running code.
  • You manage APIs as products via OpenAPI, stages and SDKs.

Reach for a reverse proxy when

  • You need full control of routing, rewriting, caching or static content.
  • You want a portable, vendor-neutral intermediary — on-prem, multi-cloud, or a sidecar.
  • Your needs sit between a plain load balancer and a gateway, and you will operate it.

Reach for a load balancer when

  • The goal is spreading traffic across healthy targets for availability.
  • You need L4 throughput and static IPs (NLB) or L7 path routing (ALB).
  • You want a managed, health-checked entry point without API-product features.
Sources
  1. Amazon API Gateway — welcome / overview — https://docs.aws.amazon.com/apigateway/latest/developerguide/welcome.html
  2. API Gateway request throttling — https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-request-throttling.html
  3. API Gateway data transformations — https://docs.aws.amazon.com/apigateway/latest/developerguide/rest-api-data-transformations.html
  4. Application Load Balancer — introduction — https://docs.aws.amazon.com/elasticloadbalancing/latest/application/introduction.html
  5. Network Load Balancer — introduction — https://docs.aws.amazon.com/elasticloadbalancing/latest/network/introduction.html
  6. ALB — authenticate users — https://docs.aws.amazon.com/elasticloadbalancing/latest/application/listener-authenticate-users.html
  7. nginx — beginner's guide (reverse proxy) — https://nginx.org/en/docs/beginners_guide.html
Related instruments