Why it matters
Rate limiter design is classic problem. Understanding shapes many services.
Advertisement
The architecture
Token bucket: refill at rate, burst up to capacity.
Sliding window: exact count in window.
Advertisement
How it works end to end
Redis: atomic increment + TTL.
Lua scripts: atomic multi-op.
Distributed: consistent hashing for scale.
Return 429 with retry-after.