Process / pipelineTelecommunicationsTraffic shapingPipeline

Token Bucket Rate Limiting Algorithm

Also known as: traffic shaping, rate limiting

OriginatorJon TurnerYear1986Sources2Related methods3

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.

Key highlights

  • 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

Intuition

This section is available to Pro members. Upgrade to Pro

How it works

This section is available to Pro members. Upgrade to Pro

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

Strengths
  • 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
Limitations
  • 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

Common pitfalls

This section is available to Pro members. Upgrade to Pro

Applications

This section is available to Pro members. Upgrade to Pro

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

  1. 1.
    Turner, J. S. (1986). New directions in communications (or which way to the information age?). IEEE Communications Magazine, 24(10), 8-15.
  2. 2.
    Heinanen, J., Guerin, R., & May, A. (1999). A Single Rate Three Color Marker. RFC 2697.

You have read it. What now?

Cite this page

ScholarGate. (2026, June 3). Token Bucket. ScholarGate. https://scholargate.app/telecommunications/token-bucket