Playground · Medium line · Station M8

API rate limiter (distributed)

Limit 8,000 API calls a second per customer using shared counters, and survive a crash.

A payments API lets each customer make 100 calls a second. Calls arrive at 8,000 a second across many servers, so every server must agree on how many calls each customer has made. If the counter store goes down, the API must keep working rather than lock everyone out.

API calls
8,000/s
Token bucket updates
8,000/s
Budget
$1,400/mo
Speed
under 100 ms
Must
Survive a crash

Reported in interviews at Amazon, Atlassian, Uber, Patreon