Course map

Project 04

API gateway and rate limiter

Request routing, traffic control

Start after Part 6

Key topics 41, 92, 96

Architecture Single high-performance service

Brief

An edge gateway for a backend fleet: route by path and host, authenticate requests, enforce per-key rate limits, apply retry and timeout policies to upstreams, emit access logs and metrics.

Targets

50k RPS · added latency p99 < 10 ms · 99.99% availability · rate-limit accuracy within 1%.

Must cover

  • Shared rate-limit state across gateway instances (→ 87).
  • No single gateway instance as a point of failure — the gateway tier is itself balanced (→ 92).
  • Auth forwarding — verified identity passed to upstreams, unverifiable requests rejected at the edge (→ 39).
  • Route policies — per-route timeout, retry, and limit configuration (P).

Design challenges

  1. Rate limiting algorithms (→ 96): implement token bucket and sliding window; compare burst behavior; make limits correct across instances (Redis with Lua, or local counters with sync — trade-off stated).
  2. Routing-table updates without restarts; health-checked upstreams with outlier ejection (→ 42, 92).
  3. Staying fast: connection pooling to upstreams, nothing blocking on the hot path (→ 5–6, 77).
  4. Failure policy per route when the auth service or Redis is down: fail open vs. fail closed, decided deliberately (→ 151 — ahead, Part 9; → 158 — ahead, Part 10).
  5. A written boundary of what does not belong in the gateway — it must not become a business-logic dumping ground (→ 41).

Out of scope

Service-mesh features (fleet-wide mTLS, traffic shifting) — → 150.

Search the guide