API Gateways, Traffic Management & the Edge›13 · Capstone: design the edge for a multi-region API

Lesson 13 of 13 · Running it

Capstone: design the edge for a multi-region API

Design the complete edge for a multi-region API with free and paid plans: global entry and failover, protection layers, gateway ownership and routing, authentication, per-tenant and per-plan limits, timeouts and retries, versioning and deprecation, observability and operations, with a reference design to compare against.

Advanced
Key wordscapstoneedge designAPI platformmulti-regionmulti-tenant APIfree and paid plansauthenticationrate limitsWAFglobal failoverGateway APIdesign review

The brief

Product:   a public REST API (plus a web app) for a project-management product
Users:     8,000 customer organisations (tenants); 120,000 daily users; partners integrate via API
Plans:     free (most tenants), team, enterprise (SSO, higher limits, EU data residency option)
Traffic:   average 3,000 requests/s, peaks of 15,000; one free tenant once sent 4,000 requests/s from a buggy script
Regions:   today one region in the US; EU region required within six months
Problems:  a scraping incident last quarter; a bad route change took every API down for 25 minutes;
           v1 endpoints still exist and nobody knows who uses them
Goals:     p99 < 400 ms for core reads; 99.95% availability; no tenant can degrade others;
           EU tenants' traffic and data stay in the EU

You're designing the entrance for a new stadium that hosts games in two cities: the ticket gates, the security checks, how many people per ticket type can enter per minute, what happens when one gate breaks, and how you know what's going on at every gate.

Your task

Write a two-to-three-page design using the outline in the cheat sheet. Draw the request path, state your assumptions, and justify each choice against the brief.

Reference design (one good version)

Path. Users → managed global edge (anycast, CDN for static assets, WAF, DDoS protection) → regional cloud load balancer → Envoy Gateway (Gateway API) in each regional cluster → services. Two regions (US, EU). Origins accept traffic only from the edge (private connectivity where available, otherwise mTLS from the edge).

Steering and residency. The edge routes by tenant home region: the token's region claim (or the tenant's subdomain) decides US or EU. EU tenants fail over only to a second EU zone or region; US tenants can fail over to a second US region later. Health checks use a synthetic read through the gateway, from several edge locations. Failover drills quarterly; target RTO 10 minutes.

Protection. WAF managed rules in count mode for two weeks, then blocking by rule group; separate rule sets for the web app and the API. Bot management on sign-in and sign-up; per-account and per-IP login limits. Request size limits (1 MB default, uploads on a dedicated route). TLS 1.2+ (1.3 preferred), HSTS, CORS restricted to the web app's origin.

Gateway and ownership. One shared public Gateway per region, owned by the platform team (listeners, certificates via cert-manager, allowed namespaces by label). Product teams own HTTPRoutes in their namespaces. Route changes go through Git, CI checks (schema, dry-run, conflict detection) and ring rollout: internal API hostnames first. Platform-wide policies need platform review.

Identity. OIDC tokens from the identity provider with tenant, plan and region claims; the gateway verifies signature, issuer, audience and expiry (remote JWKS with caching) and passes claims as headers, overwriting client values. Partners use OAuth client credentials; API keys only identify partner applications for quotas. Services re-verify tokens and do object-level authorization.

Limits. Global rate limits keyed on tenant with per-plan values: free 10 req/s, team 100 req/s, enterprise 500 req/s (contract overrides as tenant data), plus a generous local limit per gateway pod against floods. Separate, lower limits for expensive endpoints (search, export). Concurrency limits on bulk operations. Monthly quotas tracked by metering for billing. 429 with Retry-After and rate-limit headers; limits documented per plan. Rate-limit service fails open; alert if it's unavailable. The 4,000 req/s script is now capped at 10 req/s for its tenant without affecting others.

Resilience. Timeout chain: client SDK 10 s > edge 8 s > gateway 5 s request / 1.5 s per try > services' own dependencies 1 s. Retries only at the gateway, only for idempotent routes, one retry on connect failure and 503 with backoff. Circuit breakers sized from load tests; passive health checks eject failing pods. Three gateway replicas per zone set, PDBs, autoscaling on CPU and connections.

Lifecycle. OpenAPI contracts in the repo; lint and breaking-change checks in CI. Path versioning (/v2). Gateway logs per consumer show who still calls /v1; Deprecation and Sunset headers added at the gateway; partner outreach; brown-outs one month before the sunset date. Developer portal from the OpenAPI files, with keys for partners.

Operations. JSON access logs with request ID, tenant, route and response flags, to central logging; per-route RED metrics and SLO alerts (error budget burn); traces start at the gateway. Gateway and policy changes ring by ring; the 25-minute outage scenario is prevented by CI checks, ownership boundaries and staged rollout. Monthly gateway upgrades, staging first.

Risks and trade-offs. The managed edge is a dependency and a cost (accepted for DDoS capacity); the rate-limit service adds a dependency (fails open, monitored); region steering by claim means a token is needed before routing (static assets and sign-in pages are served globally); two regions double some operational work (automation and identical blueprints are preconditions).

Presenting it

  • Start from the three incidents in the brief and show which part of the design prevents each.
  • Show the numbers: limits per plan, timeout chain, replica counts, RTO.
  • Name what you deliberately left out and why.

Recap

  • An edge design covers steering, protection, gateway ownership, identity, limits, resilience, lifecycle and operations as one system.
  • Tenant and plan come from verified tokens and drive routing, limits and residency.
  • Shared gateways need ownership boundaries, CI checks and rings, because one change affects every API.

This site is a public version of my personal engineering knowledge hub. It intentionally excludes confidential company information and internal operational details.