Benchmarks#
1) Test Environment#
Python Version: 3.13.1 (CPython implementation)
Operating System: macOS Darwin 23.6.0 (ARM64 architecture)
Redis Version: 7.x (local connection)
2) Performance Metrics#
> Throughput in req/s, Latency in ms/op.
Algorithm Type |
In-Memory (Single-thread) |
In-Memory (16 threads) |
Redis (Single-thread) |
Redis (16 threads) |
|---|---|---|---|---|
Baseline [1] |
1,692,307 / 0.0002 |
135,018 / 0.0004 [2] |
17,324 / 0.0571 |
16,803 / 0.9478 |
Fixed Window |
369,635 / 0.0023 |
57,275 / 0.2533 |
16,233 / 0.0610 |
15,835 / 1.0070 |
Sliding Window |
265,215 / 0.0034 |
49,721 / 0.2996 |
12,605 / 0.0786 |
13,371 / 1.1923 |
Token Bucket |
365,678 / 0.0023 |
54,597 / 0.2821 |
13,643 / 0.0727 |
13,219 / 1.2057 |
Leaky Bucket |
364,296 / 0.0023 |
54,136 / 0.2887 |
13,628 / 0.0727 |
12,579 / 1.2667 |
GCRA |
373,906 / 0.0023 |
53,994 / 0.2895 |
12,901 / 0.0769 |
12,861 / 1.2391 |
[1] Baseline: In-Memory -
dict[key] += 1, Redis -INCRBY key increment[2] In-Memory concurrent baseline uses
threading.RLockfor thread safety[3] Performance: In-Memory - ~2.5-4.5x
dict[key] += 1operations, Redis - ~1.06-1.37xINCRBY key incrementoperations[4] Benchmark code: tests/benchmarks/test_throttled.py