Skip to content
All concepts

Concept

Token bucket

A token bucket is a rate limiter that gives each client a bucket of tokens, refilled at a steady rate up to a fixed size. Each request spends one token, and a request that finds the bucket empty is refused. The bucket size sets how large a burst is tolerated, and the refill rate sets the long-run speed.

Watch the script empty its bucket and get refused, while ordinary users never notice. A live step from the lesson Token bucket rate limit (Rate limiter). Timings and counts are illustrative.

Where you'll see it

Sources: Stripe: Scaling your API with rate limiters ↗ · RFC 6585: 429 Too Many Requests ↗ · Georgiev & Shmatikov: Gone in Six Characters (short-URL scanning) ↗ · Report a problem

The definition is in our own words; the sources are those of the lesson Token bucket rate limit.