Rate Limiting
Rate limiting caps request rates below a threshold to protect the system from overload, with fixed window, sliding window, token bucket, and leaky bucket algorithms.
Purpose
Protect the system from overload and abuse, allocating resources fairly.
Mechanism
Token bucket: adds tokens at a fixed rate; requests consume tokens, allowing bursts. Leaky bucket: requests flow out at a fixed rate, smoothing bursts. Sliding window: precisely counts requests within the window. Redis + Lua for atomic limiting.
Use cases
- API protection
- Abuse prevention
- Traffic control