Skip to main content

Very fast implementation of the token bucket algorithm.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

token_bucket-0.1.0.dev0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

token_bucket-0.1.0.dev0-py2.py3-none-any.whl (10.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file token_bucket-0.1.0.dev0.tar.gz.

File metadata

File hashes

Hashes for token_bucket-0.1.0.dev0.tar.gz
Algorithm Hash digest
SHA256 aef9d35e3b26d69c8e64e8a3027b8c71084ce8649380429af16342307381e574
MD5 ad342b703f2fce14c61edd9eed5096b9
BLAKE2b-256 91a441982f0e8b8f6cc8a76dc2c72457e5f2c48758ca3cc78cca802c8c1b84e1

See more details on using hashes here.

File details

Details for the file token_bucket-0.1.0.dev0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for token_bucket-0.1.0.dev0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 9eba11e7fd57e6c5a6a10cd0ad8416fd5d0408e18cc98fed8c0858059f8152d3
MD5 daf80345361c2a21691e67d8231fd3a4
BLAKE2b-256 0a3a88375888f664842214f3bb0c75d54f61bb18ddd5c77e7f96b00e16ef903d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page