The algorithm question — token bucket, leaky bucket, sliding window — is the warm-up, and it has a clean answer covered in depth in the Rate Limiting deep dive. This case study is the follow-up that actually separates candidates: you have one global limit and a fleet of machines. Where does the counter live?
The trap: “just count locally on each node”
It’s the answer everyone reaches for first, and it’s wrong in a specific, quantifiable way. If each of your N nodes independently allows up to the limit L, the fleet as a whole admits up to N × L — because no node can see what the others have let through.
The three places the counter can live
- One shared counter — the limit is exact
- Atomic INCR: no cross-fleet race
- Cost: a network round-trip per request
- The store becomes a hot path + dependency
- Local, no sync: fast, but admits N × L
- Divided (L/N per node): holds the cap…
- …until traffic skews and hot nodes starve
- No round-trip — coordination is the price
Every production design lands somewhere on this axis — exact-but-coordinated versus fast-but-approximate — and the interesting systems (Stripe, Cloudflare) deliberately choose approximate at the edge and exact only where money is on the line.
The members-only build makes this concrete: an interactive fleet where you watch “local counters” overshoot to N× the limit and “divided quota” starve a hot node in real time, the atomic Redis approach and why INCR beats read-modify-write, where to enforce (edge vs gateway vs service) and the fail-open-vs-fail-closed decision, the 429 + Retry-After contract, and the interview corner on making a global limit both correct and cheap.
Keep reading with Premium
You've reached the members-only part of this deep-dive — the full implementation, the interactive ring simulator, and the step-by-step walkthrough. Unlock it with a membership.
Discussion
Loading the conversation…
Discussion
Loading the conversation…