Skip to content
Omnikalc

Token bucket rate limiter calculator

Enter the refill rate, the bucket capacity and the incoming request rate to get the time before the bucket empties, the share of rejected requests, the refill time and the requests allowed in a window.

Updated on
Your inputs
tokens/s

Value out of range

tokens

Value out of range

requests/s

Value out of range

s

Value out of range

Results

Time until the bucket is empty

4.00 s

The bucket empties and requests are rejected
Share of requests rejected in the long run
33.3 %
Accepted throughput in the long run
100.0 requests/s
Time to refill an empty bucket
2.00 s
Most requests allowed in the window
1,200
Burst absorbed by a full bucket
200 requests

The token bucket rate limiter calculator gives the time before the bucket empties, the share of rejected requests, the refill time and the most requests allowed in a time window, from the refill rate, the capacity and the incoming rate.

How the calculation works

  • Enter the refill rate and the bucket capacity.
  • Enter the incoming request rate and the time window.
  • The calculator gives the time to empty, the rejected share, the accepted throughput, the refill time, the requests in the window and the burst.

Example

A limiter refills 100 tokens per second into a bucket of 200. A client sends 150 requests per second, so the bucket loses 50 tokens a second and is empty after 200 / 50 = 4.00 s. Then only 100 requests per second pass, so 33.3 % are rejected. An empty bucket needs 2.00 s to refill, and in 10 s at most 200 + 100 × 10 = 1,200 requests can be accepted.

Why it matters

The calculator helps API designers, backend developers and operators to choose the limits of a public API, a login endpoint or a message queue, and to explain the behavior to clients.

Good to know

The same algorithm shapes network traffic: routers use it to police or shape a link, with the capacity acting as the committed burst size. A client that stays below the refill rate never sees a rejection, whatever the burst, as long as bursts are shorter than the capacity allows. Choosing the capacity is a balance: a larger bucket is kinder to bursty but legitimate clients and a smaller one protects the servers better. Rejected requests should get a clear error with a hint about when to retry, and clients should back off with some randomness. Limits are often applied per key or per address, so the numbers here are for one client. Distributed limiters need shared counters and may be approximate.

The queue wait time calculator covers waiting lines, the server capacity calculator sizes servers, the network latency calculator explores delays and the VoIP bandwidth calculator shows another traffic planning case.

Frequently asked questions

How does a token bucket limit requests?

Tokens are added at a constant rate up to the capacity of the bucket. Each request removes a token, and a request that finds the bucket empty is rejected or delayed. The refill rate sets the long-term average, and the capacity sets how large a burst can pass at once.

How long can a burst last?

While the incoming rate λ is above the refill rate r, the bucket loses λ − r tokens per second, so a full bucket of b tokens lasts b / (λ − r) seconds. With 200 tokens and a surplus of 50 requests per second, that is 4 seconds. After that the client is limited to the refill rate.

How does it differ from a fixed window limit?

A fixed window of 100 requests per second lets a client send 100 at the end of one window and 100 at the start of the next, 200 in a moment. A token bucket smooths this, since the burst is bounded by the capacity. A leaky bucket goes further and releases requests at a constant rate.

Was this calculator helpful?

Thanks for your feedback!

Results are estimates provided for information purposes. They do not replace professional advice.