System Design
20. System Design Case StudiesAnimated
API Rate Limiter
Limit how often clients can call.
The idea
Counters per client in a fast store decide whether to allow each request.
Watch it work
Press play, pause, or step through. Some animations have settings you can change.
- allowed
- rejected
4 requests arrive. The bucket refills 3 tokens per tick (max 9), so bursts are allowed until it empties. 4 pass.
- tick:
- 1
- allowed:
- 4
- rejected:
- 0
1/24
Bars show how many requests were let through each tick.
Step by step
- 1Identify the client
- 2Check its counter
- 3Allow or reject
- 4Update the counter
Where it is used
Protecting APIs.
Watch out for
Races in distributed counters and burst fairness.