AlgoViz

Rate limiter algorithms

medium 30 min

Token bucket, leaky bucket, fixed window, sliding log and sliding counter: how each one counts, what it lets through, what it stores, and which to choose.

Where it shows up

The same pattern appears across everyday software.

  • Amazon API Gateway

    Documents a token bucket: the throttling rate is the refill, the burst is the capacity, and both are best effort.

  • Stripe

    Its engineering blog describes a token bucket for each user, kept in Redis.

  • Nginx

    limit_req uses the leaky bucket method. `burst` is the number that may wait, and `nodelay` passes them without delay.

  • Envoy

    The local rate limit filter applies a token bucket and answers 429 when it is empty.

  • Cloudflare

    Described the sliding window counter with its measured error.

  • GitHub

    Publishes hourly limits with the time at which the window resets, so a client can plan.