Requirements of a Rate Limiter 00:00:01 A burst outruns the report service A report service can sustain one hundred twenty requests per second. A gateway caps accepted traffic at one hundred. Send progressively larger bursts and count both completed admissions and refusals. 10 requests a second. All pass. 150 a second arrive and all reach the service, which can hold 120. 100 pass, 50 are refused with a waiting time. 500 a second. Still 100 pass and 400 are refused. The service does not notice. With one limit for all, honest users are refused too. So count per caller: the next question. 20 a second. All pass again, and nobody had to do anything. A global cap protects total capacity but says little about fairness. Decide whose work should continue when one caller consumes nearly the entire shared allowance. 00:01:04 A whole classroom shares one address Students working behind a school router look like a single address to the service. Compare a global limit, an address limit and an account limit during the same exercise. Limit 100 in total. The script takes nearly all places. Limit 10 per address. The script gets 10. But the honest users share one school address and get 10 together. Limit 10 per account. The script gets 10, each user sends one and all pass. The script owner makes ten keys. A limit for the account as a whole keeps it at 10. Choose a stable principal appropriate to the operation. Multiple tokens for one paid account may still need a common account budget, while shared network addresses can punish unrelated people. 00:01:56 Three admission decisions guard different resources Follow a request from the public edge to a gateway and then to the report planner. The final guard limits the number of reports that can run at once for one account. One address sends thousands a second. The edge stops it, far from our servers. Normal from outside, but one key is over its plan. The gateway stops it. Within the plan, but two reports of this account are already running. The service says no. Passes all three. Arrival rate and concurrent work have different units. A request can fit a per-minute allowance and still exceed a two-running-reports limit if earlier reports take a long time. 00:02:40 The quota service fails before the report service The gateway normally asks a shared store for a decision. Compare fallback rules for an inexpensive image read and a sensitive sign-in check when that store times out. The gateway asks Redis, then the service. No answer within 5 ms. The gateway must not wait longer. Photos go on, under this gateway's own local limit. Unlimited password guesses are worse than a short pause. The login is refused with Retry-After. Redis answers again. An alert and a count of errors tell what happened. Choose the risk trade-off per operation, state the local fallback's maximum possible overshoot, and monitor time spent in degraded mode. A limiter outage should have a tested exit path. 00:03:29 Count refusals for a week before enforcing them A proposed sixty-per-minute partner allowance goes into shadow mode. The simulated refusals expose a predictable morning batch as well as several genuinely broken loops. Limit 60 a minute. Count for a week, refuse nobody. 55 honest partners run a job at eight in the morning. 5 accounts are broken loops. 60 a minute with bursts of 200. The partners pass, the loops do not. Inspect real callers, timing and downstream cost before enforcement. A burst allowance may protect a valid short job while a sustained rate still controls an unending loop.