Reliabilityleaky bucket
Token bucket
Definition
A token bucket holds up to B tokens and gains R tokens per second; a request is allowed if a token is available, which permits bursts up to B while enforcing an average rate of R.
In practice
It is cheap to implement (store the token count and the last refill time) and its two parameters map directly to business rules: sustained rate and allowed burst. Most API gateways and the .NET TokenBucketRateLimiter use it.
The leaky bucket is a close relative that smooths output to a constant rate instead of allowing bursts. For a shared limit across instances, the refill and take must be atomic, for example in a Redis script.
Example
With a bucket size of 20 and a refill of 5 tokens per second, a client can send 20 requests at once and then about 5 per second after that.