- Notifications
You must be signed in to change notification settings - Fork27
Token bucket algorithm implementation for Python web apps.
License
falconry/token-bucket
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Thetoken-bucket
package provides an implementation of thetoken bucket algorithmsuitable for use in web applications for shaping or policing requestrates. This implementation does not require the use of an independenttimer 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 isreplenished gradually, rather than being immediately refilled at thebeginning of each epoch as is common with simple fixed windowcounters.
- Burst duration can be explicitly controlled.
Moving window algorithms are resistant to bursting, but at the cost ofadditional processing and memory overhead vs. the token bucketalgorithm which uses a simple, fast counter per key. The latter approachdoes allow for bursting, but only for a controlled duration.
About
Token bucket algorithm implementation for Python web apps.