Skip to main content

Very fast implementation of the token bucket algorithm.

Project description

Build Status PyPi codecov.io

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


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.0rc2.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

token_bucket-0.3.0rc2-py2.py3-none-any.whl (9.5 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: token_bucket-0.3.0rc2.tar.gz
  • Upload date:
  • Size: 6.7 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.0rc2.tar.gz
Algorithm Hash digest
SHA256 81bd2b79283b105789801c835949dd1befabb01d5d1c9a55c74d9a403c2fdfa1
MD5 1cbdceabab5ca591dfe92f3d22ac566d
BLAKE2b-256 812c315ea109960ebbffd3d4cda4ea101688453ce08f467024314ac0366f5125

See more details on using hashes here.

File details

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

File metadata

  • Download URL: token_bucket-0.3.0rc2-py2.py3-none-any.whl
  • Upload date:
  • Size: 9.5 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.0rc2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 05e8226fdf4ecdf371d18caf923a15259dcb4f1e94aa582cca3e28e3c8737108
MD5 e91e8760d01a971a592cb1c9ad96613e
BLAKE2b-256 e27c2e48355669cd6fd05b16664237903dbc3a433b730edb5ddb0647ff33c42d

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