senior System design
Design a distributed rate limiter
Design a rate limiter that protects internal services from abusive traffic. Must work across regions, share state between gateway instances, and degrade gracefully if the central store is down.
Scale targets
Users: per-user, per-IP, per-API-keyQPS: 3M req/sec peakLatency: <1ms decisionStorage: counters only — tiny
Key areas
Token bucket vs leaky bucket vs fixed windowSliding window + log trimmingLocal fast path + central reconciliationMulti-region coordinationDegraded mode (fail open vs fail closed)