Which rate limiting algorithm naturally allows short bursts while enforcing an average rate?
Options
- Fixed window counter
- Token bucket (Correct option)
- Round robin
- FIFO queue
Answer
Token bucket
Why
Picture a bucket that receives tokens at a fixed rate (e.g. 10 per second) up to a maximum (e.g. 50). Each request takes one token; no token, request rejected.
If a client was quiet, the bucket fills up, so it can send a short burst of 50 at once; over time it can never exceed 10 per second.
Fixed windows are simpler but allow double bursts at window edges.
Remember
Token bucket = steady average + allowed bursts.