KatInterview

Global Rate Limiter with Regional Distribution

System DesignModel answer
MediumModel answerSystem Designdistributed-systemsrate-limitingscalability

Last updated

Design a rate limiting service that enforces API key quotas consistently across multiple geographic regions with low latency and partition tolerance.

You need to build a rate limiting service that operates across several data centers in different geographic locations (for example, Virginia, Frankfurt, and Singapore).

Your system must:

  • Apply rate limits tied to API keys (such as 1,000 requests per minute per key), and support additional constraints like per-IP or per-endpoint limits
  • Handle requests landing in any region while keeping the limit enforced globally—not separately per region
  • Add minimal latency to the critical request path
  • Continue operating when a region becomes unavailable

After presenting your design, consider this extension:

You're building a task scheduler that executes background jobs under rate limiting constraints. Compare two scheduling approaches:

A) Execute the highest-value tasks first (sorted by priority or business value)
B) Execute the maximum number of tasks (optimize for throughput)

Discuss the trade-offs and when each approach makes sense.

Hints

Hint 1

The fundamental constraint is that cross-region communication takes 70-250ms, but you need to decide in under 2ms whether to allow a request.

Hint 2

Think about how to distribute quota across regions dynamically based on where traffic actually arrives, rather than splitting it statically.

Hint 3

Consider what happens when regions can't communicate: should the system fail open (allow requests) or fail closed (reject them)?