spike Protected
Creates a BucketConfiguration with:
a Bandwidth of the specified capacity, and a greedy refill of the specified duration.
a Bandwidth of the specified spike capacity, and an "intervally" refill of the specified spike duration.
When a token is used, both bandwidths need to have a token available.
In other words, the tokens of the greedy bucket will be progressively refilled over the duration, such as the entire bucket would have been refilled when the duration has elapsed. While the intervally refilled bucket will only be refilled once a token has been used, and the entire duration has elapsed.
This avoids users from trying to use all resources in a short time, forcing them to space out their usage.
Example
For a bucket with six tokens and a duration of 1 hour, one token will be added every 10 minutes, but if the spike bucket has 2 tokens and a duration of 10 minutes, then the user will only be able to do 2 requests at once, then wait 10 minutes before doing 2 again, until the 6 tokens / 10 minutes
bucket is empty.
Parameters
The number of tokens for the base bucket
The duration during which the tokens of the base bucket are progressively refilled
The number of tokens for the spike bucket, limiting burst usages
The duration after which the entire spike bucket will be refilled