Rate Limiting interview problems

Rate limiting is one of the most common practical interview questions because it has a small API and many design choices. You will be asked to implement allow(key) or an async acquire() using a token bucket, a fixed window counter, a sliding window log or a sliding window counter. Each one trades burst behaviour, memory and accuracy differently. In Python the core is a dict of per-key state, time.monotonic() for the clock, and arithmetic that refills tokens lazily on each call instead of running a background timer.

Interviewers look for time.monotonic() rather than time.time(), which can jump backwards. They also look for a refill that caps at capacity, float tokens instead of integer truncation that loses fractions of a token, and per-key state that eventually gets cleaned up. In the async version, the mistake is checking and decrementing tokens across an await so two coroutines both pass. A strong answer explains which algorithm fits the stated requirement, injects the clock for tests, and handles the follow-ups. Expect questions about distributing the limiter across processes and about telling a rejected caller when to retry.

1 open problem

  1. 06Sliding Window Rate Limitermedium

    Build a per-user sliding window log rate limiter that allows at most N requests in any window of W seconds.

3 locked

These open in order of demand. Open one and press I want this one to ask for it.

  1. 14Fair Async Token Bucket Lockedhard

    Implement an asyncio token bucket rate limiter that serves waiters in strict FIFO order and handles cancelled waiters without leaking tokens.

  2. 24Async Sliding Window Rate Limiter Lockedmedium

    Admit at most N requests in any rolling window of T seconds, making callers await until a slot opens.

  3. 48API Key Usage Tracker Lockedmedium

    Enforce a per-API-key sliding-window quota on both request count and tokens, rejecting requests that do not fit, with memory bounded by the window.