Try
↑ ↓ move↵ openesc close
In this lesson · topic 7 of 7
  1. 1. Why callers need a limit
  2. 2. Five ways to count
  3. 3. Race five limiters across a window edge
  4. 4. What each limiter admits at the edge
  5. 5. The sliding counter, worked by hand
  6. 6. Pricing requests and stacking limits
  7. 7. Choosing a limiter under pressure

Topic 7

Choosing a limiter under pressure

4 min read

Predict first

A public API must never let one key exceed 100 requests in any 60 seconds, because the downstream bills per call. Which algorithm fits best, and what do you give up?

Predict first

Traffic is steady at 80 percent of a token bucket's refill rate, with random gaps and clumps. Roughly what does the limiter reject?

Predict first

A team picks the sliding window log for every user of a service with millions of users. What is the first thing to worry about?

Take away

  • A limiter protects a service from one caller. It is a promise made in advance, and it does not know how busy the server is.
  • The fixed window is cheap and has a hole at its edge. The sliding log closes it at a memory cost. The sliding counter and the token bucket get close with a few numbers.
  • The sliding counter’s error is bounded by the previous window’s count. Charge expensive calls more tokens, and check narrow limits before wide ones.
  • Bucket size is burst tolerance, and refill rate is the long-run rate. The leaky bucket trades rejections for delay.

Sources

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms