⌘K
Flycodx

LLD: Implement a Rate Limiter Class

LLD: Implement a Rate Limiter Class

MediumLLD0% accepted

Implement a rate limiter class using the Token Bucket algorithm. Support per-user rate limiting with configurable capacity and refill rate. Thread-safe implementation required.

Approach

Implement thread-safe Token Bucket rate limiter with per-user tracking.

Input

Capacity=10, rate=1/sec; 15 requests in 1 second

Output

First 10 allowed; next 5 rejected; tokens gradually refill at 1/sec

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