Algorithms and Data Structures · Senior · Question 40 of 75
How does a token bucket rate limiter work?
- 1Each user gets a fixed number of requests per calendar day
- 2Requests are queued and processed in strict arrival order
- ✓Correct answer: Tokens refill at a fixed rate; each request spends one or is rejected
Explanation
The bucket's capacity allows short bursts, and the refill rate bounds the average. It needs only two numbers per key: tokens and last refill time, so it's O(1) per request.