awesome-everything RU
↑ Back to the climb

APIs

Rate limiting: multiple-choice review

Crux Multiple-choice synthesis across the rate-limiting unit — algorithm tradeoffs, the boundary burst, distributed counters, atomicity, and the 429 contract.
Your altitude — climbing toward senior
ZeroJuniorMiddleSenior
You are at senior altitude — in orbit
◷ 13 min

Six questions that cut across the whole unit. Each mirrors a design call you make under real traffic — not a definition to recite, but a tradeoff to weigh when a customer is hammering your boundary across six nodes at once.

Goal

Confirm you can connect algorithm choice, burst behaviour, the distributed-counter trap, atomicity, and the 429 contract — the synthesis the lesson built toward.

Quiz

The limit is 100/min enforced with a fixed window keyed by {key}:{minute}. What is the worst-case number of requests a client can legitimately land in a ~1-second span, and why?

Quiz

A public API serves bursty browser clients — a page load fires ~12 requests at once, then idles. You want a fair average rate that tolerates those page-load bursts. Which algorithm fits best?

Quiz

An in-memory limiter passes every test on a laptop, but in production traffic sails through far above the configured 100/min. Four app nodes sit behind the load balancer. What is the root cause?

Quiz

You move the counter to Redis and implement it as INCR followed by EXPIRE. Why is a single Lua script the more robust pattern?

Quiz

An auth service must enforce an exact per-account limit for compliance — no boundary slack, every attempt accounted for. Which algorithm, and what is the cost you accept?

Quiz

Under a fixed window you reject with 429 and a hard Retry-After of 30 seconds. At the next window edge your error rate spikes again. What happened and what is the fix?

Recap

The through-line: how requests fall into windows is where fixed window leaks its 2x boundary burst; sliding window log buys exactness with per-request memory, the sliding counter approximates it for two integers, and token bucket models bursts as a tunable capacity. None of it is real if the counter lives in per-node memory — share it in Redis, make the read-decide-update atomic with Lua, and when you reject, honor the contract with 429 + Retry-After in delta-seconds plus jitter so the reset edge does not become a thundering herd.

Continue the climb ↑Rate limiting: free-recall review
shortcuts expand
search
K
prev piece
k
next piece
j
cycle tier
t
this menu
?
sources3
expand
  1. 01
  2. 02
  3. 03

Trademarks belong to their respective owners. Editorial reference only.