Sample questions
Question 1Easy
In the token bucket algorithm:
- The count resets to zero every minute
- Every request waits a fixed delay before processing, regardless of the load
- Tokens refill at a fixed rate; each request spends one
- 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
- Bucket holds up to a capacity of tokens.
- Tokens refill at a fixed rate.
- 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:
- Compress request and response payloads to save bandwidth
- Cache responses
- Encrypt API keys
- 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
- Rate limiting caps how many requests clients can make.
- Throttling slows or limits request speed.
- 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?
- To speed up each individual request by reducing its payload size
- To protect services from overload and abuse
- To encrypt traffic
- 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
- A single client, bug or attacker can send a flood of requests.
- Rate limits cap how many requests each client may send.
- This stops one caller from using all the capacity.
- 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?
- Set-Cookie
- Retry-After
- ETag
- Content-Language
Answer: B. Retry-After
Explanation
Retry-After tells the client how long to wait before trying again.
Step-by-step solution
- A rate-limited response is a 429 Too Many Requests.
- The client needs to know when it may try again.
- The Retry-After header gives the wait time.
- 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?
- In the user's browser only
- Inside the database engine
- At the API gateway or edge
- 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
- In microservices, every request enters through the API gateway or edge.
- The gateway sees all incoming traffic.
- It can reject excess requests before they reach services.
- 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:
- Allows double bursts at window edges, like the fixed window approach
- Cannot be implemented in Redis
- Stores a timestamp per request, using lots of memory
- 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
- The sliding window log keeps a timestamp for every request.
- This makes it precise about the last window.
- At high volume, storing every timestamp takes a lot of memory.
- 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?
- Restart the API servers
- Always fail closed and block all traffic until the store recovers
- Switch to fixed window automatically
- 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
- If the limiter's store is unreachable, it cannot count requests.
- Failing closed would block all traffic, turning a small outage into a total one.
- Failing open lets traffic through, which is usually the safer default.
- 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?
- It allows unlimited bursts
- It counts requests per calendar day and resets the counter at midnight
- It has no queue or capacity
- 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
- Leaky bucket processes at a constant rate.
- Bursts are queued.
- 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?
- 20
- 50
- 12
- 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
- Starts with 10 tokens.
- Refills 2 per second for 5 seconds = 10.
- 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?
- 200
- 100
- 101
- 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
- A fixed window allows 100 requests in each one-minute window.
- The window resets at a fixed boundary, so 2 seconds can straddle two windows.
- 100 requests can arrive at the end of one window and 100 at the start of the next.
- 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 →