KatInterview

Building a High-Throughput Request Throttling System

System DesignModel answer
MediumModel answerSystem Designdistributed-systemsrate-limitingredis

Last updated

Design a service that enforces per-client request limits across a distributed application, handling 100k+ QPS with single-digit millisecond latency.

You're building a request throttling system for a platform with many backend services. Each client (identified by API key or user ID) has a request quota that must be enforced consistently, even when traffic is distributed across multiple application servers.

What You Need to Support

Your system should provide a check operation that services call before processing requests:

  • Input: an identifier (client key), a quota limit, and a time window duration
  • Output: whether the request is permitted, plus metadata like remaining quota

The system must work correctly when the same client sends requests through different application instances simultaneously.

Performance and Reliability Goals

  • Response time: Each throttling check should complete in under 10 milliseconds
  • Throughput: The system must support at least 100,000 checks per second
  • Reliability: Throttling failures should not bring down the entire platform
  • Consistency: All application instances must see the same quota state to prevent clients from exceeding limits

What to Address

  1. Overall system structure: how components fit together and where checks happen
  2. Storage backend selection: justify your choice based on the performance requirements
  3. Concurrent access: how you prevent race conditions when multiple servers check the same quota simultaneously
  4. Hot spot handling: strategies for clients that generate disproportionately high traffic

Consider which throttling algorithm to use (fixed windows, sliding windows, token buckets, etc.) and explain your reasoning. Discuss where the solution might struggle and how you'd address those limitations.

Hints

Hint 1

Think about where atomic operations can replace distributed locks

Hint 2

Consider what happens when one storage node fails

Hint 3

Memory usage differs significantly between algorithms that store every timestamp versus those that maintain counters