b2KIT

API Rate Limit Calculator

Calculate optimal API rate limiting with token bucket and sliding window algorithms visualization.

Tested tool guide Tested browser tools Checked August 15, 2026

What API Rate Limit Calculator does, with a checked example

This tool models two common rate-limiting algorithms, token bucket and sliding window, against a traffic pattern you define: request rate, burst size, bucket capacity and refill rate, or window length and limit. It simulates the timeline and shows which requests pass immediately, which wait, and which get rejected, along with a chart of token level or window occupancy over time. The detail people most often miss: a large bucket capacity only buys a temporary burst allowance. If your sustained request rate exceeds the refill rate, throttling is inevitable no matter how big the bucket is - capacity just delays the first rejection.

Worked example

A concrete input and expected output from the current implementation.

Input

Token bucket: capacity = 100 tokens, refill rate = 10 tokens/sec, incoming traffic = 15 requests/sec sustained

Expected output

Net drain rate is 5 tokens/sec (15 consumed minus 10 refilled). Starting full, the bucket empties after 100 / 5 = 20 seconds. After that point, throughput is capped at the refill rate: 10 requests/sec pass, 5 requests/sec are throttled, indefinitely.

Net drain is demand minus refill (15-10=5/sec); time to empty a full bucket is capacity divided by net drain (100/5=20s); once empty, allowed throughput can never exceed the refill rate.

How the result is produced

1

Token bucket simulation

You set a bucket capacity and a refill rate in tokens per second. The bucket starts full and gains tokens continuously up to capacity. Each request in your specified traffic pattern consumes one token if one is available; otherwise it's marked delayed or rejected. A chart plots token level over time so you can see exactly when the bucket empties and a burst starts getting throttled.

2

Sliding window counting

In sliding window mode you set a window length, e.g. 60 seconds, and a request limit. The tool tracks a rolling count of requests in the trailing window rather than since the last fixed boundary, which avoids the double-burst problem where two allowed bursts land back-to-back across a fixed-window edge. It flags which requests in your pattern exceed the limit and when.

Good uses

  • Choosing capacity and refill-rate values for a new public API before writing the rate-limiter code.
  • Explaining why a client's retry-storm traffic is getting 429s under the current limit settings.
  • Comparing how the same burst pattern behaves under token bucket versus sliding window before picking one for a gateway config.

Limits and checks

  • The simulation only knows the traffic pattern you enter (steady rate, single burst, etc.) - it cannot model real client retry behavior, clock skew, or actual production traffic logs.
  • Token bucket and sliding window are two of several rate-limiting strategies; fixed-window counters and leaky-bucket queues behave differently, so results won't transfer directly if your gateway (NGINX, Envoy, AWS API Gateway, Cloudflare) implements a different algorithm internally.
  • Numbers assume a single, centralized bucket or window. Rate limits enforced across multiple distributed servers require synchronization overhead and slack that the calculator does not account for.

Common questions

Will these numbers match what my API gateway actually enforces?

Only if the gateway implements the same algorithm and parameters you entered. Many gateways use variants, such as fixed window or distributed counters with eventual consistency, that behave differently at the edges, so treat this as a planning aid, not a guarantee of production behavior.

Which algorithm should I pick, token bucket or sliding window?

The tool doesn't recommend one - it shows the behavior of each against your pattern so you can compare. Both allow bursts: token bucket lets a request burst consume however many tokens have accumulated, up to capacity, while sliding window lets requests burst up to the full window limit within any trailing window. Sliding window's advantage isn't a lack of burst allowance - it's that it avoids the fixed-window edge case where two full bursts land back-to-back across a boundary, briefly doubling the effective rate. The right choice depends on your traffic shape and your API's tolerance for burstiness.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools