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.0rc2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 05e8226fdf4ecdf371d18caf923a15259dcb4f1e94aa582cca3e28e3c8737108 |
|
MD5 | e91e8760d01a971a592cb1c9ad96613e |
|
BLAKE2b-256 | e27c2e48355669cd6fd05b16664237903dbc3a433b730edb5ddb0647ff33c42d |