Design a Rate Limiter

viaLeetCode

Requirements: Design a rate limiter for an API that restricts how many requests a client can make in a given time window.

Design: Fixed Window: count requests per fixed time bucket (e.g. per minute), reset the counter each new window — simple but allows bursts at window boundaries. Sliding Window (log-based, e.g. via Redis sorted sets): store a timestamp per request and count how many fall within the trailing window, trimming old entries — accurate but more memory. Leaky Bucket: requests are queued and processed at a fixed constant rate, smoothing bursts. Token Bucket: tokens refill at a fixed rate into a bucket of fixed capacity; a request is allowed only if a token is available, allowing controlled bursts up to the bucket size.

Add a follow-up question they asked
No follow-ups yet. Be the first to add one.
asked …
LeaderboardSalary
Language
Account