Distributed Rate Limiter
Throttle abusive traffic without throttling yourself.
Throttle an abuse surge on the hot path without adding latency or toppling a node.
The limiter sits in front of every request. It must add almost no latency and keep deciding even as the API fleet loses a node mid-surge.
Components in play
- Edge LB — Spreads traffic across the fleet.
- Rate limiter — Atomic counter check on every request.
- API servers — Do the actual work once allowed.
- Datastore — Backs the API.
Graded on these SLOs
- ≥ 98.50%Requests survive
- ≤ 85 msHot-path p99
- ≥ 8.0k rpsServe the legit load
- ≤ 90%Headroom
The brief
Design a rate limiter that caps how many requests a user/API key can make in a window, shared across a fleet of stateless servers. It sits in the hot path of every request, so it must be fast and must not become a single point of failure.
Functional
- Limit requests per key over a time window
- Configurable limits per route/plan
- Consistent decisions across all servers
Non-functional
- Microsecond-ish overhead on the hot path
- Resilient — a limiter outage shouldn't take down the API
- Scales horizontally with the fleet
Read the deep dive
14 min readA rate limiter is the one component that touches every single request before any useful work happens. That position is what makes it both critical and dangerous: if it is slow, the whole API is slow; if it is down, the whole API can be down; if it is wrong, you either let an abusive botnet through or you throttle your paying customers. The job sounds trivial — count requests per key, reject past a threshold — but the moment you put it in front of a fleet of stateless servers, the counting has to be shared, atomic, and microsecond-cheap all at once. This guide walks from a blank requirements sheet to the exact reference architecture the SysGym simulator grades you against: a token-bucket limiter backed by a central atomic counter store, sitting in front of a generously replicated API, designed to fail open. The scenario throws 8,000 requests per second at you, doubles it to 16,000 during an abuse surge, settles to 1.6x sustained pressure, then kills API replicas at 12s and 28s and stalls the API tier mid-surge at 20s. The targets are availability at or above 98.5 percent, hot-path p99 at or below 85 ms, sustained throughput at or above 8,000 rps, and peak saturation at or below 90 percent. We will derive each design choice and show the math that clears those bars.
Warm-up: design decisions
Optional theory to prime the calls a senior engineer would make before you build.
Run first, save progress later
The simulator is open without an account. Create one after your run to reveal the score, take the quiz and keep your progress.
- AI design coach on your canvas — pins failure points & over-engineering
- Honest AI design review on every run
- All 12 problems + unlimited chaos simulator
- Points, levels & leaderboard