DevTools Logo

Rate Limiter Simulator

Rate Limiter Simulator

Replay one traffic timeline through token bucket, leaky bucket and window limiters — then compare every admission side by side.

Runs in your browser
Try an example

Traffic & parameters

120 rps · 10s

Algorithms to compare

Capacity means bucket size, queue depth, or per-window limit. Rate drives the token refill and leaky outflow.

Manual events

Outcome timeline

1,440 events · — ms
Sliding counter is an approximation: compare its lane with the exact log lane.
Single-node teaching model — distributed limiters use coordination and behave differently.
Admission statistics per algorithm
AlgorithmAcceptedRejectedRejected %Max / sRejection run
1,09934123.68%1206s
1,09934123.68%1206s
1,00044030.56%10010s
1,00044030.56%10010s
1,00044030.56%10010s

Compare lanes

▮ accepted · ▮ rejected

Token bucket1099 accepted · 341 rejected
Leaky bucket (queue)1099 accepted · 341 rejected
Fixed window1000 accepted · 440 rejected
Sliding window log1000 accepted · 440 rejected
Sliding window counter1000 accepted · 440 rejected

Token bucket — formula & detail

tokens = min(capacity, tokens + Δt · rate); start full at t = 0, spend 1 per accepted request.

First rejections: 4.138s, 4.146s, 4.150s, 4.158s, 4.167s, 4.175s, 4.179s, 4.188s, 4.196s, 4.200s, 4.208s, 4.217s (+329 more)

Sliding window log keeps one timestamp per in-flight request: memory is O(requests in window).

Token bucket binned outcomes, 0.125 seconds per bin
Start (s)AcceptedRejected
0.000150
0.125150
0.250150
0.375150
0.500150
0.625150
0.750150
0.875150
1.000150
1.125150
1.250150
1.375150
1.500150
1.625150
1.750150
1.875150
2.000150
2.125150
2.250150
2.375150
2.500150
2.625150
2.750150
2.875150
3.000150
3.125150
3.250150
3.375150
3.500150
3.625150
3.750150
3.875150
4.000300
4.1251416
4.2501317
4.3751218
4.5001317
4.6251218
4.7501317
4.8751218
5.0001317
5.1251218
5.2501317
5.3751218
5.5001317
5.6251218
5.7501317
5.8751218
6.000123
6.125132
6.250123
6.375132
6.500123
6.625132
6.750123
6.875132
7.000123
7.125132
7.250123
7.375132
7.500123
7.625132
7.750123
7.875132
8.000123
8.125132
8.250123
8.375132
8.500123
8.625132
8.750123
8.875132
9.000123
9.125132
9.250123
9.375132
9.500123
9.625132
9.750123
9.875132
Leaky bucket (queue) binned outcomes, 0.125 seconds per bin
Start (s)AcceptedRejected
0.000150
0.125150
0.250150
0.375150
0.500150
0.625150
0.750150
0.875150
1.000150
1.125150
1.250150
1.375150
1.500150
1.625150
1.750150
1.875150
2.000150
2.125150
2.250150
2.375150
2.500150
2.625150
2.750150
2.875150
3.000150
3.125150
3.250150
3.375150
3.500150
3.625150
3.750150
3.875150
4.000300
4.1251416
4.2501317
4.3751218
4.5001317
4.6251218
4.7501317
4.8751218
5.0001317
5.1251218
5.2501317
5.3751218
5.5001317
5.6251218
5.7501317
5.8751218
6.000123
6.125132
6.250123
6.375132
6.500123
6.625132
6.750123
6.875132
7.000123
7.125132
7.250123
7.375132
7.500123
7.625132
7.750123
7.875132
8.000123
8.125132
8.250123
8.375132
8.500123
8.625132
8.750123
8.875132
9.000123
9.125132
9.250123
9.375132
9.500123
9.625132
9.750123
9.875132
Fixed window binned outcomes, 0.125 seconds per bin
Start (s)AcceptedRejected
0.000150
0.125150
0.250150
0.375150
0.500150
0.625150
0.750105
0.875015
1.000150
1.125150
1.250150
1.375150
1.500150
1.625150
1.750105
1.875015
2.000150
2.125150
2.250150
2.375150
2.500150
2.625150
2.750105
2.875015
3.000150
3.125150
3.250150
3.375150
3.500150
3.625150
3.750105
3.875015
4.000300
4.125300
4.250300
4.3751020
4.500030
4.625030
4.750030
4.875030
5.000300
5.125300
5.250300
5.3751020
5.500030
5.625030
5.750030
5.875030
6.000150
6.125150
6.250150
6.375150
6.500150
6.625150
6.750105
6.875015
7.000150
7.125150
7.250150
7.375150
7.500150
7.625150
7.750105
7.875015
8.000150
8.125150
8.250150
8.375150
8.500150
8.625150
8.750105
8.875015
9.000150
9.125150
9.250150
9.375150
9.500150
9.625150
9.750105
9.875015
Sliding window log binned outcomes, 0.125 seconds per bin
Start (s)AcceptedRejected
0.000150
0.125150
0.250150
0.375150
0.500150
0.625150
0.750105
0.875015
1.000150
1.125150
1.250150
1.375150
1.500150
1.625150
1.750105
1.875015
2.000150
2.125150
2.250150
2.375150
2.500150
2.625150
2.750105
2.875015
3.000150
3.125150
3.250150
3.375150
3.500150
3.625150
3.750105
3.875015
4.0001515
4.1251515
4.2501515
4.3751515
4.5001515
4.6251515
4.7501020
4.875030
5.0001515
5.1251515
5.2501515
5.3751515
5.5001515
5.6251515
5.7501020
5.875030
6.000150
6.125150
6.250150
6.375150
6.500150
6.625150
6.750105
6.875015
7.000150
7.125150
7.250150
7.375150
7.500150
7.625150
7.750105
7.875015
8.000150
8.125150
8.250150
8.375150
8.500150
8.625150
8.750105
8.875015
9.000150
9.125150
9.250150
9.375150
9.500150
9.625150
9.750105
9.875015
Sliding window counter binned outcomes, 0.125 seconds per bin
Start (s)AcceptedRejected
0.000150
0.125150
0.250150
0.375150
0.500150
0.625150
0.750105
0.875015
1.000123
1.125132
1.250123
1.375132
1.500123
1.625132
1.750123
1.875132
2.000123
2.125132
2.250123
2.375132
2.500123
2.625132
2.750123
2.875132
3.000123
3.125132
3.250123
3.375132
3.500123
3.625132
3.750123
3.875132
4.0001317
4.1251218
4.2501317
4.3751218
4.5001317
4.6251218
4.7501317
4.8751218
5.0001317
5.1251218
5.2501317
5.3751218
5.5001317
5.6251218
5.7501317
5.8751218
6.000123
6.125132
6.250123
6.375132
6.500123
6.625132
6.750123
6.875132
7.000123
7.125132
7.250123
7.375132
7.500123
7.625132
7.750123
7.875132
8.000123
8.125132
8.250123
8.375132
8.500123
8.625132
8.750123
8.875132
9.000123
9.125132
9.250123
9.375132
9.500123
9.625132
9.750123
9.875132

Examples

Fixed-window boundary double burst

Input
Pattern: steady · 100 rps · 10s
Capacity: 100 · Window: 1s
Algorithms: Fixed window, Sliding window log
Output
Fixed window: 200 accepted between t = 0 and t = 2
Sliding log: about 100 accepted per sliding second

Two full windows meet at t = 1: the fixed counter resets, so 200 requests pass in a single second measured across the boundary.

Sliding counter approximation error

Input
Manual events: t = 0.9, 0.99, 1.1
Capacity: 2 · Window: 1s
Algorithms: Sliding log, Sliding counter
Output
Sliding log: accept, accept, reject
Sliding counter: accept, accept, accept

The counter estimates 2 × (2 − 1.1) = 1.8 in-flight requests at t = 1.1 and admits one more than the exact log.

Leaky queue delay

Input
Manual events: t = 0, 0.05, 0.05, 0.15, 0.3
Rate: 10/s · Queue depth: 2
Output
Accepted: 4 · Rejected: 1 · Peak queue: 2 · Mean wait: 0.125s · p95: 0.15s

Service completions are scheduled at 0.1, 0.2, 0.3 and 0.4 seconds; the duplicate request at t = 0.05 finds a full queue.

About this tool

Rate Limiter Simulator replays one generated traffic timeline through token bucket, leaky bucket (queue), fixed window, sliding window log and sliding window counter limiters. Because every algorithm sees the same request arrivals, the accepted/rejected ticks line up in time and burst behavior can be compared with numbers rather than adjectives.

The traffic generator offers steady, burst, ramp and seeded Poisson patterns, an aggregate requests-per-second rate, a 1-second-to-10-minute duration and up to five weighted clients. You can also add or remove individual arrival events; a custom timeline is marked as such and the generated seed no longer applies. Scope can be one shared limiter or independent per-client limiters, which changes how the same traffic is admitted.

Capacity has a per-algorithm meaning: token reserve, queue depth, or the maximum count per window. Rate drives token refill and leaky outflow; window length drives the two window families. The exact sliding log and the weighted-counter approximation can be enabled together to make the approximation error visible. All computation, charting and CSV export happen locally in the browser.

What this tool does not do

  • Single-node semantics only: no Redis-style coordination, node sync or partial failure is modeled.
  • Token bucket starts full at t = 0 and refills continuously; a gateway that starts empty or refills discretely will differ on the first requests.
  • Leaky bucket is the queue/shaper flavor; the leaky-bucket-as-meter (GCRA) variant is not simulated.
  • Statistics use aligned 1-second bins for max admissions and rejection runs; finer-grained definitions will produce different numbers.
  • Timelines are capped at 100,000 events; charts are binned when a run is large, while statistics remain exact for the capped timeline.
  • Request cost is always one; weighted endpoints and byte-based quotas are out of scope.

How to use this tool

  1. Pick a traffic pattern

    Choose steady, burst, ramp or seeded Poisson, then set the aggregate rps, duration, burst multiplier and client weights.

  2. Select the lanes

    Toggle the algorithms to overlay. Use the presets for burst absorption, the fixed-window boundary demo, a strict window, a smooth shaper or two-client scope.

  3. Tune the limiter

    Set rate, capacity and window length, and choose shared or per-client scope. Results re-simulate as you edit.

  4. Compare and export

    Read the statistics table and lanes, hover a bin for exact counts, then copy the summary or download all events as CSV.

Use cases

Choose a limiter for a public API

Run the same burst through all lanes and decide whether occasional burst admission or strict sliding-second fairness matters more for your clients.

Tune gateway protection

Compare rejection rates and longest rejection runs before deploying a rate/capacity/window combination to an API gateway.

Teach throttling algorithms

Show the fixed-window boundary flaw and the token-vs-leaky tradeoff with visible admissions, rejections and queue delays.

Check fairness across clients

Toggle shared versus per-client scope with weighted clients to see how one noisy client affects everyone else.

Algorithm parameters and semantics

AlgorithmMeaning of rate, capacity and window
Token bucketStarts full at t = 0; tokens = min(capacity, tokens + Δt · rate). Each accepted request spends one token. Continuous refill, so short bursts can pass.
Leaky bucket (queue)Accepted requests are served FIFO at rate/s. Capacity is the maximum queue depth (capped at 10,000); a full queue rejects. Wait time is service time minus arrival.
Fixed windowRequests are counted in aligned windows of floor(t / window). The counter resets at each boundary; an event exactly at n·w belongs to the new window.
Sliding window logAccepts when fewer than capacity timestamps lie in (t − window, t]. Exact, but memory grows with requests in the window.
Sliding window counterEstimates usage as previousCount · overlapFraction + currentCount against the same capacity. Cheaper than a log, but approximate; back-loaded previous windows are over-counted.

All lanes are single-node models on the same timeline. Scope chooses one shared state machine or one per client; no coordination or distributed consensus is simulated.

Common mistakes

Mistake:Treating capacity as the same quantity in every lane.

Fix:It is a token reserve for token bucket, a queue depth for leaky bucket, and a per-window request limit for the window algorithms; the formula card names the mapping.

Mistake:Expecting the sliding counter to match the sliding log exactly.

Fix:It is a weighted approximation of the previous window. Enable both lanes to see where it over- or under-counts, and use the log when exactness matters.

Mistake:Reading the fixed-window spike as a sliding-second violation.

Fix:Fixed windows are aligned to the clock. Up to 2× the limit can cross a boundary even though no single sliding second exceeds it — that is the point of the comparison.

Mistake:Assuming the simulator models a distributed limiter.

Fix:It uses single-node state machines. Real distributed limiters add coordination, sync delay and partial failure; treat the numbers as a teaching aid.

Frequently asked questions

Which algorithm absorbs bursts best?

Token bucket, when the reserve is large enough: it starts full, refills continuously and can admit a whole burst at once, then rejects while it recovers. Leaky bucket also accepts the burst but spreads service over time, adding queueing delay. Fixed and sliding window limiters admit at most the configured number per window, so they reject the surplus immediately. Run the Burst preset to compare all four on one timeline.

Why does the fixed window allow 2× traffic at boundaries?

Its counter is reset at each aligned window boundary (window = floor(t / windowSeconds)). A client can send the full limit just before the boundary and the full limit just after it, so 200 requests can arrive within one second with a 100-per-window limit. Sliding window log and counter avoid this by looking back over a moving interval.

What is the difference between token and leaky buckets?

A token bucket meters admissions: tokens accrue at the configured rate up to capacity, and a request is accepted if a token is available. A leaky bucket queues accepted requests and serves them FIFO at a fixed rate, rejecting when the queue is full. The first trades strictness for burst tolerance; the second trades admission for predictable outbound pacing and added wait time.

Does sliding window cost more memory?

The exact sliding window log does: it stores one timestamp for every accepted request still inside the window, so memory is O(requests in window). The sliding window counter stores only the current and previous window counts, but it is an approximation — the tool shows both lanes together so the error is visible.

What about distributed rate limiting?

This simulator models a single node with perfect, immediate state. Distributed limiters add coordination messages, sync intervals, clocks and failure modes, so the same nominal limit can admit more across nodes. Use the numbers here to choose an algorithm and parameters, then validate against your gateway or service mesh in a load test.

References & standards