Skip to content
System Designer

System design interview preparation

Design a rate limiter

Design a rate limiter for a public API. Reason about caller limits, shared counters and failure policies, then test the matching game scenario.

Play the matching problem

Define who gets an allowance

A rate limiter decides whether a caller may do more work. For a public API, the useful question is usually how much one customer can use without crowding out everyone else. Name the caller identity, time window and burst allowance. An IP address may represent many people behind one network. A customer key gives a different boundary. State which one the promise uses before placing the limiter in a diagram.

Make a counter decision safely

A shared allowance needs the check and update to act as one operation. If two servers read the same balance and both spend it, the limit is weaker than it appears. Explain where the authoritative counter lives, how callers are divided among counters and what happens when one customer becomes unusually busy. A local counter is fast, but a global allowance needs a rule for sharing or dividing the budget.

Choose an outage policy

If the limiter cannot answer, allowing work protects availability but risks overload. Refusing it protects the downstream service but also rejects legitimate callers. The right choice depends on the cost of the operation and the customer promise. Keep admission ahead of expensive work. Give rejected callers a useful retry policy so a brief limit does not become a retry storm. Discuss these protocol choices separately from the capacity measured by the game.

Try the traffic experiment

Use the requirements below to size a baseline, then run the full simulated day. Watch which request path is under pressure during a burst or failure. Compare refusal, waiting and additional capacity as different choices with different consequences. Record the event, affected requests and measured result before making a change. In a design discussion, use that evidence to explain what the limiter protects and what still fails when a dependency cannot answer.

The matching game brief

Developers call your public API from scripts and apps. A few misbehaving or malicious clients can crowd out everyone else. Build limits that are fair, fast and cheap, and that survive a retry storm.

Who uses it
2 million developers
Audience in plain numbers
2,000,000 users or devices
Normal peak
≈ 20,000 requests per second
Request mix
Read: 85%; Write: 15%
Speed for 99 of 100 requests
Read: ≈ 250 ms; Write: ≈ 250 ms
Successful requests
99.9%
Data safety
At most 1 minute of writes may be lost.
Monthly budget
≈ $89,000
Data at rest
≈ 1 TB
Where users are
North America: 60%; Europe: 40%
Home region
North America
Waiting deadlines
Read: 900 seconds; Write: 3,600 seconds

≈ marks an approximation, just as in the game. Waiting deadlines measure the age of queued work and are separate from interactive response time.

  • Estimate memory for 2 million counters at about 100 bytes per key, including overhead.
  • Typical limit: 5,000 requests an hour per key, bursts allowed (approx.).

Play the rate limiter for a public api problem or read the full problem and clarification answers.

Playing on systemdesigner.io needs a free Google or GitHub account. These pages, the lessons and the guides can be read without one. Figures in the game are teaching approximations.

Study the decisions

Read the full walkthrough for estimates, alternatives and failure cases.

More interview practice