CONCEPT SHEET · Concepts

API Gateway

One-liner: Single entry point in front of services that handles routing, auth, rate limiting, and protocol translation so services don't.

ArticleConcepts© Arthur Bernier Jr445 words1 code block

Say this#

How it works#

TEXT
client -> DNS -> [L4/L7 LB] -> [API Gateway] -> service A                                     |---------> service B                                     |---------> service C
  1. TLS terminates at LB or gateway.
  2. Gateway authenticates (JWT verify, API key lookup), applies rate limit (Redis-backed counters).
  3. Matches route → target service, rewrites path/headers, adds correlation ID.
  4. Optional: transform payload, aggregate calls (BFF), cache GETs.
  5. Returns response; emits metrics/logs/traces.

Gateway vs load balancer: LB distributes identical traffic; gateway understands the API and makes policy decisions. Gateway vs service mesh: gateway is north-south (edge), mesh (Istio/Linkerd sidecars) is east-west (service-to-service).

Trade-offs#

ChoiceProCon
Single gatewayOne place for auth/limits/observabilitySPOF and bottleneck if not horizontally scaled; team coupling
BFF per clientTailored payloads, mobile vs webMore code to maintain
Logic in gatewayServices stay thinGateway becomes a "smart pipe" monolith; deploy coupling
Managed (AWS API GW)No ops, built-in throttling/authPer-request cost, latency, vendor limits
Self-hosted (Kong/Envoy)Control, performanceYou run it HA

Numbers#

  • Gateway hop typically adds ~1-5 ms (order of magnitude), more for managed cloud gateways.
  • AWS API Gateway default account throttle: 10,000 req/s with 5,000 burst (soft limit); 29 s integration timeout.
  • Nginx/Envoy single instance: tens of thousands of req/s on commodity hardware.

In the interview#

See also