Rate limiting: four algorithms, one distributed problem
Every rate limiter answers the same question — may this request proceed? — and the four standard algorithms differ only in what they remember. This builds the token bucket and the sliding window from scratch, shows the burst the fixed window lets through, and then confronts the part that is actually hard: making the counter correct across many servers.
What you'll be able to do
- Implement a token bucket and state the two numbers that define it
- Demonstrate the 2x burst a fixed-window counter permits at a boundary, and fix it
- Choose between token bucket, leaky bucket, fixed window, and sliding window log by naming the memory each one costs
- Design the distributed counter, including what happens when the limiter's own store is down
Before this: back-of-the-envelope
The rest of this lesson is in the app
Every rate limiter answers the same question — may this request proceed? — and the four standard algorithms differ only in what they remember. This builds the token bucket and the sliding window from scratch, shows the burst the fixed window lets through, and then confronts the part that is actually hard: making the counter correct across many servers. This walkthrough runs about 26 minutes, with runnable code you can edit and re-run as you read.
Continue in ChannelPulseThe first module of every track is free to read on the web — see what's open in System design.