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

Uploaded Source

Built Distribution

token_bucket-0.3.0rc1-py2.py3-none-any.whl (9.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file token_bucket-0.3.0rc1.tar.gz.

File metadata

  • Download URL: token_bucket-0.3.0rc1.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.5.0.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.2

File hashes

Hashes for token_bucket-0.3.0rc1.tar.gz
Algorithm Hash digest
SHA256 af4b2577171f835a213fcf1716fae05cb83acbf7d02a5ee8b21cd2c434c95d5c
MD5 705dbd94f361e49fe0a90972dc81cdf2
BLAKE2b-256 359f56a2bef02bd3a1b5486e2286f8673d25864326fb345b7aca2c84e54a8eee

See more details on using hashes here.

File details

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

File metadata

  • Download URL: token_bucket-0.3.0rc1-py2.py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.5.0.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.2

File hashes

Hashes for token_bucket-0.3.0rc1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 074cbbfc00b87dc20270419edc39455c549ee7da0ff97b0743acc6fd039040a3
MD5 6e1fe99e1f70795a009ade3e31c13cc7
BLAKE2b-256 f2c552b963c9a9c469d9e411015edcc00001f177fb66977cc85dfd5d5ff9c976

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