Skip to content
SD-9 · API RATE LIMITER · INTERACTIVE

Break it.
Then fix it.

A few API keys are flooding you at 25 times their limit. Turn up the traffic, watch what leaks and what melts, and add the parts a real rate limiter needs.

CHALLENGEAt 1M req/s, let through under 1% of over-limit traffic, add under 1 ms of latency, and drop nothing.
StatusDOWNAt 1M requests per second
Over-limit let through0%Target under 1%
Added by the limiter18.05 msp99, target under 1 ms
Errors85%Good requests failing
API clientsLIVE
500K/s fair · 500K/s flood
3 keys at 25× their limit
API gateways × 40OK
Token bucket, shared
1.0M / 1.6M req/s
Counter storeDOWN
One call per request
1.0M / 150K ops/s
Limits configOK
Cached in every gateway
refresh every 30 s
429 Too Many Requests429
With Retry-After
480K/s turned away
API backendOK
0% of the excess gets in
520K / 750K req/s
If the counter store stalls, every API call stalls. Every request now waits for the store. Give each check a 5 ms timeout and, when it fires, fall back to the gateway’s own count. A rate limiter must never take the API down with it.
2Numbers per bucketTokens left and the time of the last refill. 10M buckets fit in about 1 GB.
N×Leak of local countsWith N gateways and no shared state, a key gets N times its limit.
5 msTimeout, then fail openA broken limiter should let traffic through, not block it.
10×Fewer store callsGateways take tokens in batches of 10 and spend them locally.
Want the reasoning behind every switch?Visual walkthroughFull write-up
Was this lab useful?Your vote tells us what to improve next.