What Is Token Bucket Algorithm?

The token bucket algorithm enables a network to allow or deny requests based on current traffic. Each bucket holds a certain number of tokens that represent network requests (e.g., attempting to log into an account or sending a message). Whenever a user sends a request, another token gets added to the bucket.

Since the bucket has a set limit of how many tokens it can hold, the algorithm stops operations if users make too many requests in a short time. The network drops all new requests until a "bucket refill" resets the number of allowed tokens.