Giter VIP home page Giter VIP logo

token-bucket's Introduction

Token Bucket

What is a Token Bucket?

A token bucket is a simulation of a bucket that is filled with tokens by a tap at a linear rate over time, and offers the facility to withdraw tokens at any time.

This project provides a token bucket of finite capacity; that is, when the bucket reaches its configured capacity, depositing additional tokens will not change the volume of tokens in the bucket. Also, this implementation will never give more tokens than are available in the bucket.

While this project was conceived for the purposes below, it could be adapted to any scenario in which such facilities are useful.

Purpose

  1. Configurable rate limiting with a sliding window.
  2. Avoid unnecessary multi-threading in the tap implementation.

Usage Model

The client of the token bucket has the following requirements:

  • some action(s) should only be permitted to occur at a desired rate (e.g. for service fairness, privacy, cost containment)
  • different actions may have different costs, representable by requiring an appropriate number of tokens
  • the rate may be difficult to express in pure terms of x actions per time frame: burst rate and sustained maximum rate are two such concepts which are handled well by a token bucket.

Specification of Behaviour

Refer to the TokenBucketSpec for a specification of how the token bucket behaves in each scenario. If you'd like to see addtional or alternative behaviour, both pull requests and feature requests are always welcome. Please also provide feedback on any bugs.

token-bucket's People

Contributors

auidah avatar

Stargazers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.