Rate Limiter Comparison
Four algorithms on one burst pattern
Send the same traffic at a token bucket, a leaky bucket, a sliding-window log, and a sliding-window counter. Watch which requests they admit and which they drop. The algorithms disagree not about fairness in general, but about which customer gets hurt by a burst.
traffic pattern
rate (req/s)4
burst / capacity10
admitted
62
rejected
33
admit rate
65.3%
Tokens accumulate at the configured rate up to the burst size. Each request consumes one. Idle time is banked; bursts are allowed up to what was saved.
The choice is never the cleanest algorithm — it is the shape of the traffic you actually see, and what kind of unfairness you can afford.