Skip to content
System design · Staff · 14 min

Design a rate limiter for a public API across 3 regions

Local token buckets with asynchronous global reconciliation, and what you give up when a region is partitioned.

Prompt

A public API serves 400k requests/s across three regions. Each API key has a limit (default 1,000 req/s). Design a limiter that enforces limits within 10% accuracy, adds less than 2 ms p99, and keeps working when the regions cannot talk to each other.

Questions worth clarifying

  • 10% over-admission is acceptable; under-admission is not
  • Limits are per key, per second; a few hundred keys have custom limits
  • Decision must be made in the request path, in-region
  • Partition behaviour: fail open with local limits

Inputs you will estimate from

Total requests/sRegionsActive API keysCounter sync intervalDefault limitDecisions/s per limiter nodeState per key
Open to everyone until Pro goes on sale · sign in to save your attemptOpen the workbench with live capacity math
Open in the app