Rate Limiting Questions with Answers

14 practice questions on Rate Limiting (System Design) with answers and step-by-step solutions. Try 10 samples below, then practise all 14 free in the AptiNest app.

Sample questions

Question 1Easy

In the token bucket algorithm:

  1. The count resets to zero every minute
  2. Every request waits a fixed delay before processing, regardless of the load
  3. Tokens refill at a fixed rate; each request spends one
  4. Requests leak out at a constant rate from a queue

Answer: C. Tokens refill at a fixed rate; each request spends one

Explanation

Bursts up to the bucket capacity are allowed, while the long-run rate is bounded by the refill rate.

Step-by-step solution

  1. Bucket holds up to a capacity of tokens.
  2. Tokens refill at a fixed rate.
  3. Each request consumes one.

Why the other options are wrong

  • A. A per-minute reset is a fixed window.
  • B. Fixed delay is not token bucket.
  • D. That is the leaky bucket.

Question 2Easy

Throttling and rate limiting both aim to:

  1. Compress request and response payloads to save bandwidth
  2. Cache responses
  3. Encrypt API keys
  4. Control how fast clients can use a resource

Answer: D. Control how fast clients can use a resource

Explanation

Both restrict usage rate; throttling often slows requests rather than rejecting them outright.

Step-by-step solution

  1. Rate limiting caps how many requests clients can make.
  2. Throttling slows or limits request speed.
  3. Both control client usage rate.

Why the other options are wrong

  • A. Compression is unrelated.
  • B. Caching reduces load differently.
  • C. Encryption is unrelated.

Question 3Easy

Why do APIs use rate limiting?

  1. To speed up each individual request by reducing its payload size
  2. To protect services from overload and abuse
  3. To encrypt traffic
  4. To make responses smaller

Answer: B. To protect services from overload and abuse

Explanation

Limits stop a single client, bug or attacker from consuming all capacity.

Step-by-step solution

  1. A single client, bug or attacker can send a flood of requests.
  2. Rate limits cap how many requests each client may send.
  3. This stops one caller from using all the capacity.
  4. So rate limiting protects services from overload and abuse (option B).

Why the other options are wrong

  • A. Rate limiting does not reduce payload size.
  • C. Encryption is TLS, not rate limiting.
  • D. Rate limiting does not change response size.

Tip: Rate limits protect shared capacity from any one caller.

Question 4Easy

A rate-limited response should ideally include which header to guide clients?

  1. Set-Cookie
  2. Retry-After
  3. ETag
  4. Content-Language

Answer: B. Retry-After

Explanation

Retry-After tells the client how long to wait before trying again.

Step-by-step solution

  1. A rate-limited response is a 429 Too Many Requests.
  2. The client needs to know when it may try again.
  3. The Retry-After header gives the wait time.
  4. So the header to include is Retry-After (option B).

Why the other options are wrong

  • A. Set-Cookie sets a cookie and does not guide retry timing.
  • C. ETag identifies a version of a resource for caching, not retry timing.
  • D. Content-Language gives the language of the body, not retry timing.

Tip: Send Retry-After with 429 and 503 responses so clients know how long to wait.

Question 5Easy

Where is rate limiting commonly enforced in a microservices system?

  1. In the user's browser only
  2. Inside the database engine
  3. At the API gateway or edge
  4. In the CI pipeline

Answer: C. At the API gateway or edge

Explanation

The gateway sees all incoming traffic and can reject excess before it reaches services.

Step-by-step solution

  1. In microservices, every request enters through the API gateway or edge.
  2. The gateway sees all incoming traffic.
  3. It can reject excess requests before they reach services.
  4. So rate limiting is commonly enforced at the API gateway or edge (option C).

Why the other options are wrong

  • A. The browser can be bypassed, so it cannot enforce limits alone.
  • B. The database engine is too late and does not see API traffic.
  • D. The CI pipeline runs builds and tests, not live traffic.

Tip: Enforce rate limits at the edge so excess traffic never reaches services.

Question 6Medium

The sliding window log algorithm is accurate but:

  1. Allows double bursts at window edges, like the fixed window approach
  2. Cannot be implemented in Redis
  3. Stores a timestamp per request, using lots of memory
  4. Ignores the client identity

Answer: C. Stores a timestamp per request, using lots of memory

Explanation

Keeping every request timestamp is precise but costly at high volume.

Step-by-step solution

  1. The sliding window log keeps a timestamp for every request.
  2. This makes it precise about the last window.
  3. At high volume, storing every timestamp takes a lot of memory.
  4. So the drawback is memory use: it stores a timestamp per request (option C).

Why the other options are wrong

  • A. The sliding window log does not allow double bursts at edges; that is the fixed window flaw.
  • B. It can be implemented in Redis, for example with sorted sets.
  • D. It keeps per-client records, so it does not ignore client identity.

Tip: Sliding window log is exact but costly; the sliding window counter is a cheaper estimate.

Question 7Medium

Should a rate limiter fail open or fail closed if its Redis store is unreachable?

  1. Restart the API servers
  2. Always fail closed and block all traffic until the store recovers
  3. Switch to fixed window automatically
  4. Usually fail open, unless abuse risk is severe

Answer: D. Usually fail open, unless abuse risk is severe

Explanation

Blocking all users because the limiter is down turns a minor outage into a total one; sensitive endpoints may choose otherwise.

Step-by-step solution

  1. If the limiter's store is unreachable, it cannot count requests.
  2. Failing closed would block all traffic, turning a small outage into a total one.
  3. Failing open lets traffic through, which is usually the safer default.
  4. So usually fail open, unless abuse risk is severe (option D).

Why the other options are wrong

  • A. Restarting API servers does not decide the failure mode and is not a limiter choice.
  • B. Always failing closed causes a total outage when the store is down.
  • C. Switching to fixed window does not address the store being unreachable.

Tip: Fail open for ordinary endpoints; fail closed only where abuse risk is severe.

Question 8Medium

How does the leaky bucket algorithm differ from the token bucket?

  1. It allows unlimited bursts
  2. It counts requests per calendar day and resets the counter at midnight
  3. It has no queue or capacity
  4. It drains requests at a constant rate, smoothing bursts

Answer: D. It drains requests at a constant rate, smoothing bursts

Explanation

Leaky bucket queues requests and drains them at a fixed rate; token bucket permits bursts up to its capacity.

Step-by-step solution

  1. Leaky bucket processes at a constant rate.
  2. Bursts are queued.
  3. Output is smooth.

Why the other options are wrong

  • A. Token bucket allows bursts, not leaky.
  • B. That is fixed window.
  • C. It has a queue with capacity.

Question 9Hard

A token bucket has capacity 10 and refills 2 tokens/s. Starting full, what is the most requests it can accept in the first 5 seconds?

  1. 20
  2. 50
  3. 12
  4. 10

Answer: A. 20

Explanation

It can spend the 10 stored tokens at once plus the 2 × 5 = 10 tokens refilled: 20.

Step-by-step solution

  1. Starts with 10 tokens.
  2. Refills 2 per second for 5 seconds = 10.
  3. Max = 10 + 10 = 20.

Why the other options are wrong

  • B. 50 ignores the capacity limit.
  • C. 12 counts only one second of refill.
  • D. 10 ignores the refill.

Question 10Hard

A fixed-window limiter allows 100 requests per minute. What is the worst-case number of requests accepted within about 2 seconds?

  1. 200
  2. 100
  3. 101
  4. 150

Answer: A. 200

Explanation

100 at the end of one window and 100 at the start of the next pass both windows' limits.

Step-by-step solution

  1. A fixed window allows 100 requests in each one-minute window.
  2. The window resets at a fixed boundary, so 2 seconds can straddle two windows.
  3. 100 requests can arrive at the end of one window and 100 at the start of the next.
  4. So the worst case is 200 requests in about 2 seconds (option A).

Why the other options are wrong

  • B. 100 is the limit per full window, but two windows can each pass 100 near the boundary.
  • C. 101 is not a bound; the boundary effect allows up to 200.
  • D. 150 is not the worst case; the boundary allows 200.

Tip: Fixed windows allow double bursts at the boundary; sliding windows reduce this.

Practise all 14 questions free

The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.

Open this topic in the app →

Related topics

See all System Design topics · All topics