← All problems
Dashboard
Courses
Problems
Badges
Theme
Sign inStart free
Problem 002 · APIs and application architecture

Design a Rate Limiter

Medium 45 min

Design a distributed rate limiter that sits in front of a public API. Each API key may make a fixed number of requests per window. Limits must hold even when traffic is spread across many gateway instances.

Functional requirements

  • Limit requests per API key per time window
  • Return HTTP 429 with a retry hint when limited
  • Support different limits per plan

Non-functional requirements

  • Adds under 5 ms to request latency
  • Limits are accurate within 1% across instances
  • The API keeps serving if the limiter degrades

Constraints and scale

  • 50 000 requests per second at peak
  • 1 million active API keys
  • Deployed in 3 regions

You will practise

  • Compare token bucket and sliding window
  • Share counters across instances
  • Decide between failing open and failing closed
Show 2 hints
  1. Where does the counter live so all gateway instances see it?
  2. What happens to traffic if the counter store is down?

Ready to build?

Open the canvas, place your components and explain your decisions. Your draft saves automatically.

Sign in to start

Failure scenarios

  • Counter store becomes unavailableThe shared counter store stops responding for two minutes.

Run them from the workspace once your design is in place.