⌘K
Flycodx

Design a Rate Limiter

Design a Rate Limiter

EasySystem Design0% accepted

Razorpay needs to limit API calls per user to prevent abuse. Design a rate limiter that allows at most N requests per user per minute. Describe algorithms, data structures, and trade-offs between token bucket, leaky bucket, and sliding window counter approaches.

Approach

Design a rate limiter allowing N requests/user/minute.

Input

N=100 req/min, 1M users

Output

Redis sliding window: ZREMRANGEBYSCORE + ZADD + ZCARD per request; O(1) amortized

Scenarios & Expected Answers

Sign in to continue

Create a free account to view answers and mark progress.

  • Free forever — no credit card
  • Theory Q&A with detailed answers
  • Points, streaks & leaderboards
Auto Save On