AlgoViz

Design a rate limiter

medium 45 min

Protect services against overload, abuse and surprise bills.

Where it shows up

The same pattern appears across everyday software.

  • Stripe API key tiers

    Its engineering blog describes a token bucket for each user, kept in Redis, beside limits on requests in flight and load shedding. The documentation lists 100 requests a second in live mode and 25 in a sandbox.

  • GitHub REST and GraphQL limits

    Allocates 5,000 requests per hour for authenticated accounts and 60 requests per hour for anonymous clients, and returns the time at which the window resets in a response header. GraphQL counts points.

  • AWS API Gateway throttling

    Implements token bucket throttling with configurable burst capacity and steady-state rates, and documents that limits are targets, not guaranteed ceilings.

  • Cloudflare

    Counts in each data center, with counters shared only among data centers at one location: speed before a world-wide exact count.

  • Envoy

    Offers both shapes: a local token bucket in each proxy, and a global filter that asks a rate limit service, with a setting for open or closed on failure.

  • Kong

    One plugin, three strategies: counters in the node, in the cluster's database, or in Redis.