throttled-py#
Introduction#
throttled-py is a high-performance Python rate limiting library with multiple algorithms(Fixed Window, Sliding Window, Token Bucket, Leaky Bucket & GCRA) and storage backends (Redis, In-Memory).
Features#
Supports both synchronous and asynchronous (
async / await).Provides thread-safe storage backends: Redis, In-Memory (with support for key expiration and eviction).
Supports multiple rate limiting algorithms: Fixed Window, Sliding Window, Token Bucket, Leaky Bucket & Generic Cell Rate Algorithm (GCRA).
Supports configuration of rate limiting algorithms and provides flexible quota configuration.
Supports immediate response and wait-retry modes, and provides function call, decorator, and context manager modes.
Supports integration with the MCP Python SDK to provide rate limiting support for model dialog processes.
Excellent performance, The execution time for a single rate limiting API call is equivalent to (see Benchmarks for details):
In-Memory: ~2.5-4.5x
dict[key] += 1operations.Redis: ~1.06-1.37x
INCRBY key incrementoperations.