Performance

The performance of each rate-limiting strategy and storage backend differs in both throughput and storage cost characteristics.

Performance by storage and strategy

Below you will find benchmarks for each strategy and storage giving a high level overview of the performance.

Benchmark parameters
  • 100 unique virtual users (i.e. unique rate limit keys)

  • A rate limit of 500/minute

  • Each virtual user’s limit was pre-seeded to be 50% full.

See Benchmark run details for information on the benchmarking environment.

Performance of hit() by storage & strategy.

Performance of test() by storage & strategy.

Performance of get_window_stats() by storage & strategy.

Performance implication of limit sizes

For Fixed Window and Sliding Window Counter both the storage cost and performance of operations remains mostly constant when the limit window and size varies. This is not always true for Moving Window which maintains a complete log of successful requests within the rate limit window. This has both a cost and computation implication depending on the limit size and load.

Benchmark parameters
  • 100 unique virtual users

  • Rate limits of

    • 500/minute

    • 10000/day

    • 100000/day

  • Each virtual user’s limit was pre-seeded to be:

    • 5% full.

    • 50% full.

    • 95% full.

See Benchmark run details for information on the benchmarking environment.

Performance of limits.strategies.FixedWindowRateLimiter.hit() with different rate limits and storages and with each rate limit pre-seeded to different percentages to show the implications of limit size.

Performance of limits.strategies.FixedWindowRateLimiter.test() with different rate limits and storages and with each rate limit pre-seeded to different percentages to show the implications of limit size.

Performance of limits.strategies.FixedWindowRateLimiter.get_window_stats() with different rate limits and storages and with each rate limit pre-seeded to different percentages to show the implications of limit size.

Performance of limits.strategies.SlidingWindowCounterRateLimiter.hit() with different rate limits and storages and with each rate limit pre-seeded to different percentages to show the implications of limit size.

Performance of limits.strategies.SlidingWindowCounterRateLimiter.test() with different rate limits and storages and with each rate limit pre-seeded to different percentages to show the implications of limit size.

Performance of limits.strategies.SlidingWindowCounterRateLimiter.get_window_stats() with different rate limits and storages and with each rate limit pre-seeded to different percentages to show the implications of limit size.

Performance of limits.strategies.MovingWindowRateLimiter.hit() with different rate limits and storages and with each rate limit pre-seeded to different percentages to show the implications of limit size.

Performance of limits.strategies.MovingWindowRateLimiter.test() with different rate limits and storages and with each rate limit pre-seeded to different percentages to show the implications of limit size.

Performance of limits.strategies.MovingWindowRateLimiter.get_window_stats() with different rate limits and storages and with each rate limit pre-seeded to different percentages to show the implications of limit size.

Benchmark run details