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

Log in to read the rest of this lesson

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. A new account gets 7 days of Pro free, no card required.

Log in to continue

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