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.2.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 2 Python 3

File details

Details for the file token_bucket-0.2.0.tar.gz.

File metadata

File hashes

Hashes for token_bucket-0.2.0.tar.gz
Algorithm Hash digest
SHA256 76305d9dbe875d3b033b5bf208cc2cf78c003129378108ab1bae919a42b108da
MD5 262d8639072296b53cd5be342396bb89
BLAKE2b-256 74fb5c7681fce00acca5df34d63f1b4ee441df72157a92b24e4992f00e69e6c1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for token_bucket-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e25aec9cce401447f3588a70d5c45336d460d4fac90f20156bbda26f83fc1aae
MD5 55e1cd06f27211f23ea127f832579645
BLAKE2b-256 eaae31fe6fd239796bf60012f69b1ec3a090bedaf74ec23c8c23d94003144963

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