System design · Mechanisms — replication, queues, limits, and placement

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.

26 min read Full lesson in the app Patterns: token-bucket, sliding-window, fail-open

What you'll be able to do

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 ChannelPulse

The first module of every track is free to read on the web — see what's open in System design.