Skip to content

Latest commit

 

History

History
34 lines (25 loc) · 1.79 KB

File metadata and controls

34 lines (25 loc) · 1.79 KB

Design an API gateway

A single entry point in front of many backend services that handles routing, auth, and cross-cutting concerns.

Requirements

  • Route incoming requests to the right backend service.
  • Handle authentication, rate limiting, and TLS termination in one place.
  • Be highly available and low latency.
  • Support many services and high request volume.

Key ideas

  • The gateway routes by path or host to backend services, so clients see one endpoint instead of many.
  • Cross-cutting concerns live here: authentication and authorization, rate limiting, TLS termination, request and response transformation, and logging.
  • It must not become a single point of failure: run it behind a load balancer as a redundant, stateless fleet.
  • Caching and circuit breaking protect slow or failing backends.

High-level design

flowchart LR
    Client --> GW{{API Gateway}}
    GW --> S1[Service A]
    GW --> S2[Service B]
    GW --> S3[Service C]
    Auth[Auth / Rate limit] -.-> GW
Loading

Go deeper