Token bucket rate limiting algorithm is… #flashcard
Idea: Tokens (permissions to proceed) are added to a bucket at a fixed rate. Each request consumes one token. If no tokens are available, the request is denied or delayed.
- Pros:
- Allows short bursts of traffic (if tokens accumulated).
- Smooths out long-term rate to the refill rate.
Use case: APIs that need to tolerate burstiness but enforce average rate (e.g., 100 reqs/sec on average but allow bursts up to 200).
- Analogy: Like a vending machine where coins (tokens) are replenished over time. No coin = no snack.
<!--ID: 1753886610143-->