Stackbook Logo
architecture-descriptionestablished · medium operational burden

API Gateway

Also known as: gateway, edge-gateway, backend-for-frontend

Intent

Single entry point for clients that handles cross-cutting concerns: routing, auth, rate limiting, observability, protocol translation.

Problem

Clients calling multiple services directly creates tight coupling, duplicate cross-cutting logic, and observability gaps.

Forces

  • Multiple services with different protocols (HTTP, gRPC, GraphQL)
  • Cross-cutting concerns: auth, rate limiting, logging, tracing
  • Clients need simplified contracts (BFF pattern)
  • Service mesh vs gateway: different layers, different concerns

Solution

✓ When to Use

  • Multiple services exposed to external clients
  • Need centralized auth, rate limiting, observability
  • Protocol translation required
  • BFF: different clients (web, mobile, partner) need different shapes

✗ When Not to Use

  • Single service (no routing needed)
  • Internal service-to-service (use service mesh)
  • Ultra-low latency path where extra hop hurts
  • Simple architectures where gateway adds complexity

Pros

  • +Centralizes cross-cutting concerns
  • +Decouples clients from service topology
  • +Enables gradual migration (strangler fig)
  • +Single place for security policies

Cons

  • Single point of failure (mitigate: HA, multi-AZ)
  • Added latency (one network hop)
  • Gateway becomes bottleneck (scale horizontally)
  • Logic creep: business logic leaks into gateway

Cost Profile

Infrastructure

Medium — managed (Kong, AWS API GW) or self-hosted (Envoy, Traefik)

Operational

Medium — config management, cert rotation, scaling

Cognitive

Low — well-understood pattern

Failure Modes

  • Gateway down → all external traffic down

  • Config error → routing loops, auth bypass, rate limit misfire

  • Upstream overload: gateway queues requests, OOM

  • Certificate expiry → TLS failures

Real-World Examples

Alternatives

  • service-mesh
  • sidecar-proxy
  • direct-client-calls

Related Patterns

  • service-mesh
  • rate-limiting
  • circuit-breaker
  • auth-gateway
  • bff

Competency Domains

distribution communicationsecurity compliancereliability opseconomics evolution