Enrichment · STEM Explorations · A token bucket against a steady stream
A token bucket lets a client send a burst up to the bucket size and then only as fast as tokens refill. Each request costs one token. Give the bucket size, the refill rate, the rate the client sends at and a window of seconds, starting with a full bucket. The page works out when the bucket runs dry, how many requests get through and how many are turned away.
The worked example is A 20-token bucket refilling at 5 per second, a client sending 12 per second for 10 seconds. Nothing you type leaves this browser.
Loading the calculator. If nothing appears, turn on JavaScript.
Requests arrive at a steady rate and cost one token each. The model is continuous. The example is made up.
Enrichment · STEM ExplorationsOpen to everyone · no sign-in
Tokens in, tokens out.
A bucket holds up to a set number of tokens and gains tokens at a steady rate. Each request removes one. If the bucket is empty the request is refused. A quiet client builds up a full bucket and can then send a burst, while a heavy client is held to the refill rate.
It protects a shared service from being overwhelmed while still allowing short bursts that real applications produce. Many web services answer a refused request with the status code 429, too many requests, and often say how long to wait.
Figures worked from your own numbers. Nothing you type is sent to Caveat. The worked example is made up. Your entries stay in this browser. Support: team@caveatacademic.com.