Design a Rate Limiter

Design a rate limiter that restricts how many requests each client can make to an API.

API gateway feature · Easy

Functional requirements

  • Limit requests per user or API key per time window
  • Return HTTP 429 when the limit is exceeded
  • Different limits per plan

Scale & non-functional requirements

  • Works across many API servers
  • Adds under 5 ms latency
  • Keeps working if the limiter store is briefly down

Hints

  • Token bucket vs sliding window — trade-offs?
  • Where do counters live so all servers share them?
  • Fail open or fail closed?

More system design questions

Try AI Flowchart free →