Token Bucket Rate Limiting Algorithm
Also known as: traffic shaping, rate limiting
Token bucket is a simple and elegant algorithm for traffic shaping and rate limiting. A virtual bucket accumulates tokens at a fixed rate (the committed information rate). Incoming packets consume tokens (one token per byte); packets are transmitted only if sufficient tokens are available. If the bucket is full, excess tokens are discarded (no carry-over). Token bucket bounds peak rate and allows controlled bursts, making it ideal for traffic management in networks.
Read the full method
Sign in with a free account to read this section.
Method map
The neighbourhood of related methods — select a node to explore.
When to use it
Token bucket is used in QoS systems (RFC 2697, RFC 2698) for traffic policing and shaping. Use token bucket when average rate should be controlled but short bursts are acceptable. Avoid token bucket if strict peak rate must be enforced (use leaky bucket). Token bucket is standard in DiffServ traffic conditioning.
Strengths & limitations
- Simple algorithm: easy to implement in hardware or software
- Fair: all flows shaped to same rate regardless of arrival pattern
- Allows bursts: up to bucket capacity, useful for bursty traffic
- Tunable: rate R and capacity C control behavior
- Efficient: O(1) per-packet computation
- Allows peaks above average rate (burst size up to C)
- Tokens are lost if bucket overflows; no feedback to sender
- Not optimal for all traffic types; some traffic benefits from different shaping
- Sharing bucket between flows is complex; per-flow buckets required
Frequently asked
What is the difference between token bucket and leaky bucket?
Token bucket allows bursts (up to capacity); leaky bucket enforces strict peak rate by dropping packets exceeding capacity. Token bucket is more lenient for bursty traffic.
How is token rate tuned?
Token rate R (tokens/second) determines average throughput: R * bytes/token = bits/second. Bucket capacity C determines burst size: C bytes. Tune R for desired average rate, C for acceptable burst.
What if a packet exceeds bucket capacity?
If packet size > bucket capacity, the packet will always be dropped or queued indefinitely. Packets should be smaller than bucket capacity; if necessary, increase C.
How does token bucket interact with congestion?
Token bucket limits sender injection rate but doesn't prevent congestion downstream. Combine with active queue management (AQM) at congestion points.
Sources
How to cite this page
ScholarGate. (2026, June 3). Token Bucket Rate Limiting Algorithm. ScholarGate. https://scholargate.app/en/telecommunications/token-bucket
Which method?
Set this method beside its closest kin and read them side by side — the library lays the books on the table; the choice is yours.
Compare side by side →