InterviewLegend

Design a Distributed Rate Limiter

Commonly asked
Alex Chen40 min readUpdated 37 real interview reports

It sounds small and hides a real distributed-systems problem. The job is simple to state. For every incoming request, decide in a millisecond or two whether to allow it or reject it. On a reject, return HTTP 429 with a Retry-After header so a well-behaved client knows to back off. The limiter exists to protect the API from overload and to keep one merchant's traffic burst from starving everyone else. The trap is the word "distributed." The decision runs on a fleet of many API servers, so the count of how much a merchant has used cannot live on one server. It has to be shared, and sharing a fast-changing counter across a fleet is where the design gets interesting.

Frame the goal before drawing anything. Abuse detection, fraud scoring, and billing all live elsewhere. What this system does is smooth load. A merchant gets a steady rate of requests plus some room to burst. Past that we shed their excess, so the shared API stays healthy for everyone behind it. The limiter has to be far cheaper than the work it guards, since it runs on the hot path of every single call. And it has to honor the limit fleet-wide even though no single server sees all the traffic.

The Stripe angle
Stripe literally published this design, so the round is really checking whether you can rediscover it. Stripe's engineering blog "Scaling your API with rate limiters" lays out four kinds of limiter working together and names token bucket in Redis as the core mechanism. Get to token bucket and shared Redis state on your own and you show you have run an API in production. It also ties straight to the idempotency story: a 429 is a retryable response, so a client that gets one backs off and retries under the same idempotency key, never a fresh charge. Connect the limiter to safe retries and you have shown why Stripe cares about both at once.
What's inside
  • 1 diagram
  • 5 sections
  • about 40 min

Premium lessonStripe interview guide

These took digging.

What candidates walked out with, from 20,000+ reports, forum threads behind logins and write-ups in Chinese. Then solved step by step.

100 companies. Checked every month.

Unlock all 100 companies

$49 a year · less than $1 a week · Cancel anytime

Had your Stripe interview?Tell us what they asked. Reviewed before it goes in, never with your name.
Stripe interview guide

Know what Stripe asks before you walk in.

21 coding · 4 system design · 31 behavioral questions

Get Premium$49 a year · Cancel anytime
Or start freeNo card.

Get their questions first.

InterviewLegend is independent and not affiliated with or endorsed by any company it covers.