Command Palette

Search for a command to run...

PHASE 14Advanced ~6 min· topic 6 of 8

Topic 14.6

Rate Limiting (Production)

In one line

The production-shaped limiter: global policies, edge enforcement, quotas per tenant, and the fail-open story.

0/8 · 0%

Think of it like this

The nightclub bouncer idea, but now applied fairly across an entire company's APIs, per customer, per feature — so one demanding customer can't accidentally (or on purpose) starve everyone else of service.

Key ideas

  1. 01

    Standardize on: Redis-backed (10.9/12.2), Lua atomicity, per-key (tenant, API key, IP, endpoint), config-driven rules.

  2. 02

    Enforcement layers: edge (gateway/CDN WAF — cheap, flat) + in-service (business-aware) — defense in depth.

  3. 03

    Failures: Redis outage → fail-open with a local budget (each node allows its share) vs fail-closed (429 everyone) — decide per endpoint.

  4. 04

    Response contract: 429 + Retry-After + X-RateLimit-* headers — clients self-throttle.

  5. 05

    Quota types: burst + sustained (token bucket) and daily caps (fixed window) coexist.

  6. 06

    Interview: 'rate limits are a product feature — they need versioned rules, dashboards, and a fail-open strategy'.

Explain without notes

01

Redis is down for a minute. For a checkout endpoint vs a search endpoint — fail open or closed? Why different?

Practice

01

Design the rate-limit config model (per api/tenant, burst+caps) and the Redis failover behavior.

Trade-offs

  • ↔

    Edge-only limits miss business-aware rules; in-service limits miss early cutoffs — the two go together.

Run it in production

Completion checklist

  • I can present rate limiting layered and with an honest failure story.

Back to phase