A refiller drips tokens into a bucket at a fixed rate, and every request has to take one token to reach the server. A full bucket lets a short burst straight through, which is what token bucket is known for. An empty one answers with a 429. Below, an attacker joins two ordinary users: watch who gets hurt when they share one bucket, and when each has their own.
Each dot stands for 579 real requests, and each token for 579 real tokens. Time is not scaled. At 1x speed the first 429 comes 5.0 s after the first request reaches the gate, which is the drain time the formula below predicts.
Busiest hour vs the daily average. The book's estimate uses 2x.
Seconds of peak traffic a full bucket can absorb.
1. Average requests per second
2. Peak requests per second
3. Refill rate r
4. Bucket size b
5. What is arriving right now
Doubling DAU doubles the traffic, and because r and b are sized from that same traffic, it doubles them too. Every ratio stays the same, so the bucket behaves identically and only the number each dot stands for changes. What changes the behaviour is traffic relative to r: the peak factor, the burst window, and the attack.
Steps 1 and 2 are the estimation method from the back-of-the-envelope chapter of Alex Xu's System Design Interview, Vol. 1, including its 2x peak. Bucket size and refill rate are the two token bucket parameters from its rate limiter chapter. The book does not give a single formula joining them; steps 3 to 5 are that join, written here, and the drain time and drop rate follow directly from them.
AWS uses token buckets in several places and documents the parameters, which makes them good examples to study.
All three are AWS's own documentation (primary sources). The quoted sentences are short attributed quotations; the worked examples are calculated here from AWS's published figures. AWS revises limits, so check the pages for current values.