Very fast implementation of the token bucket algorithm.
Project description
A Token Bucket Implementation for Python Web Apps
The token-bucket package provides an implementation of the token bucket algorithm suitable for use in web applications for shaping or policing request rates. This implementation does not require the use of an independent timer thread to manage the bucket state.
Compared to other rate-limiting algorithms that use a simple counter, the token bucket algorithm provides the following advantages:
The thundering herd problem is avoided since bucket capacity is replenished gradually, rather than being immediately refilled at the beginning of each epoch as is common with simple fixed window counters.
Burst duration can be explicitly controlled
Moving window algorithms are resistant to bursting, but at the cost of additional processing and memory overhead vs. the token bucket algorithm which uses a simple, fast counter per key. The latter approach does allow for bursting, but only for a controlled duration.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for token_bucket-0.3.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6df24309e3cf5b808ae5ef714a3191ec5b54f48c34ef959e4882eef140703369 |
|
MD5 | e242207ee93a8ff65b8dbd1a2a4af891 |
|
BLAKE2b-256 | 4bce61ee52521766059d2c2537e85ba5f9773313e74b86df14652a61dd2e990e |