API gateway
API Design

Meaning

An API gateway is a server that sits between clients and a collection of backend services, acting as a single entry point that routes requests, aggregates responses, and enforces cross-cutting concerns. It addresses the pain of clients having to know the topology of every internal service and the duplication of auth, rate limiting, and logging logic across services. Engineers reach for it whenever a system grows beyond a handful of services or needs to expose internal APIs to external consumers with consistent policy enforcement.

Primary Function

API management

Communicative Purpose

Centralizes cross-cutting concerns (authentication, rate limiting, routing, observability) across multiple backend services behind a single entry point.

Pattern

client → API gateway → backend services (with auth, rate limiting, routing, aggregation)

Função primária

API management

Propósito comunicativo

Centralizes cross-cutting concerns (authentication, rate limiting, routing, observability) across multiple backend services behind a single entry point.

Situações de gatilho

Microservices: routing external requests to multiple internal services through one endpoint; Cloud architecture: exposing internal APIs through a unified public-facing URL; Distributed systems: enforcing auth, throttling, and logging centrally without modifying each service

Contextos

Microservices architectures, cloud-native systems, Kubernetes ingress layers, AWS API Gateway / GCP Apigee / Azure API Management, serverless backends, BFF patterns

Padrão

client → API gateway → backend services (with auth, rate limiting, routing, aggregation)

Colocados típicos

  • reverse proxy
  • load balancer
  • service mesh
  • microservices
  • authentication
  • rate limiting
  • request routing
  • circuit breaker
  • OAuth2
  • JWT

Substituições comuns

  • Service mesh sidecar (e.g.
  • Istio): finer per-service control but more operational complexity
  • Direct service exposure: simpler but loses centralization and cross-cutting policy
  • BFF (Backend for Frontend): gateway variant tailored to one client type

Erros comuns

Treating API gateway as a plain load balancer: gateways add protocol translation, auth, and aggregation, not just traffic distribution; Deploying a single gateway instance without HA: creates a single point of failure for the whole system; Embedding business logic inside the gateway: violates single responsibility and couples unrelated services; Ignoring added network hop: every request pays latency cost and the gateway becomes a bottleneck under load; Confusing AWS API Gateway (the managed service) with the general pattern: the pattern is broader and predates the AWS product

Similar / contraste

Reverse proxy: simpler, no business logic or aggregation; Service mesh: per-service sidecar vs centralized entry point; Load balancer: distributes traffic but does not transform requests; BFF: gateway variant tailored to a specific client (mobile, web)

Interferências

Coming from monolith: may try to embed gateway logic inside the application — the gateway is a separate infrastructure concern that should not own business rules; Coming from serverless: may assume API Gateway means only the AWS managed service — the pattern is general and applies to any cluster of services

Família do chunk

  • reverse proxy
  • service mesh
  • load balancer
  • BFF
  • sidecar pattern
  • ingress controller

Nuance

When NOT to use: small monoliths or systems with only 2–3 services where the operational overhead exceeds the benefit; Performance: every request adds at least one network hop and serialization cost, so gateways must be horizontally scaled and kept stateless; Boundary conditions: long-lived connections (WebSockets, gRPC streaming) require gateway support for streaming protocols, and gateway-level caching can mask backend failures if not invalidated correctly

Efeito pragmático

Hides internal service topology from clients so services can be refactored independently, centralizes security and rate-limit policy so it is applied uniformly, and provides a single observability point for traffic across the system.

Dica de memória

API gateway: like a hotel front desk — guests (clients) only see one entrance, but behind the scenes the desk routes them to the right room (service), checks credentials, and enforces house rules.

Upgrade path

Service mesh (Istio, Linkerd) for fine-grained per-service traffic management, mTLS, and canary routing

Frequência: HighFormulaicidade: FlexiblePrioridade de aquisição: Recognition firstPrioridade de output: BothTag de espaçamento: Medium-term

Log in to save chunks.