Very fast implementation of the token bucket algorithm.
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 resitant 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.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size token_bucket-0.2.0-py2.py3-none-any.whl (10.4 kB)||File type Wheel||Python version py2.py3||Upload date||Hashes View|
|Filename, size token_bucket-0.2.0.tar.gz (6.6 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for token_bucket-0.2.0-py2.py3-none-any.whl