ScaleCrafts

Design a distributed rate limiter

MediumAlgorithmsRedisConsistency

Limit how many requests each user or API key can make in a time window, across a fleet of servers.

Functional requirements

  • Limit requests per user, IP or API key
  • Rules are configurable per endpoint
  • Rejected callers learn when they can retry

Non-functional requirements

  • Adds under 5 ms to each request
  • Limits hold across many API servers
  • If the limiter fails, traffic still flows

Scale

  • 1M active API keys
  • 500K requests per second at peak

How you’ll be scored

7 checks covering your diagram and your notes, and any valid approach counts. Hints appear for anything you miss. Common mistakes, such as single points of failure or components you never explain, cost points. How grading works

What interviewers look for

  • Clarify before you draw. State what is in and out of scope. For “Design a distributed rate limiter”, that starts with: Limit requests per user, IP or API key; Rules are configurable per endpoint; Rejected callers learn when they can retry. Interviewers notice candidates who pin the requirements down first.
  • Turn the scale into numbers. The scale (1M active API keys; 500K requests per second at peak) should become requests per second, storage and bandwidth, and those figures should drive your choices. Estimates with units carry more weight than adjectives.
  • Show how each quality is met. Your design should visibly deliver: Adds under 5 ms to each request; Limits hold across many API servers; If the limiter fails, traffic still flows. Saying that it does isn’t enough; point to the part of the design that makes it true.
  • Expect follow-ups on the hard parts. Interviewers usually probe algorithms, redis and consistency here. This is a medium problem, so interviewers expect you to weigh two reasonable options, such as consistency against latency, and to say why you picked one.
  • Explain failure and trade-offs. Say what happens when a component fails, where a single point of failure would hurt, and what you chose not to build. Naming a trade-off is a stronger answer than claiming there isn’t one.

Related problems

Loading your workspace…