Bucket capacity with multiple bandwidths #350
-
Hi, I'm struggling to understand how the capacity is set up for a bucket.
In my project I define 2 bandwidths:
pretty much as in documentation. Can someone clarify how this works? Thank you |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Answer 1Bandwidth limit = Bandwidth.simple(1000, Duration.ofHours(1)); According to source code the code above equals to following: int capacity = 1000;
Refill.greedy(1000, Duration.ofHours(1))
Bandwidth limit = Bandwidth.classic(capacity, refill)
Answer 2Capacity, currently available tokens, and last refill date are maintended independently for each bandwidth. Answer 3It will be minimum available tokens from all bandwidths. If you need to access for more detailed stat then Verbose API can help(see javadoc for VerboseResult). |
Beta Was this translation helpful? Give feedback.
Answer 1
According to source code the code above equals to following:
capacity
specifies the maximim amount of tokensrefill
specifies the speed(and style) in which consumed tokens are returned back.Answer 2
Capacity, currently available tokens, and last refill date are maintended independently for each bandwidth.
Aggregated acapacity for whole bucket is useless and never used. Aggregated available tokens is taken as minimum from all bandwidths. If first bandwidth has 3 available tokens, second bandwidth has 1…