New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for fixed interval refill #39
Comments
When this feature will be available? |
Most likely in January 2018 |
I need this feature soon, can you try for oct end? |
Yes, I can try, please hire me via upwork. I am agree to fixed price project 1000 US dollars. |
@vtahlani do you still need in this feature? |
Yes.
…On Wed, Mar 28, 2018, 2:36 AM Vladimir Bukhtoyarov ***@***.***> wrote:
@vtahlani <https://github.com/vtahlani> do you still need in this feature?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#39 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AMtxyCp4kA9d2xQPXtwzrvrInEjOWqNaks5tiqnUgaJpZM4OCsV2>
.
|
@vtahlani I have a little time frame to implement new release |
@vtahlani I remember that this feature will not be included to current release if you will not provide use cases. |
Thanks for implementing the feature. With current smooth refill tokens are regenerated in millisecond so it is hard to say that a token was consumed as I get same value for X-RateLimit-Remaining header in subsequent requests if throttling number is big (e.g. 500 and it would become even more hard as this number become bigger). Also as tokens get refilled in milliseconds then in a minute I would be serving more request than my limit. I also faced another challenge what should be the value for X-RateLimit-Reset when should i say it would be rest. With fixed rate interval, i believe, we can solve these problems - i would serve only request equivalent to my limit, i would be able to tell my client when it is going to reset. Please let me know if you need more details. |
This is because the token-bucket allows local burst by design. You can not avoid the burst, independently of smoot or interval refill style. For example:
It is interesting option, thanks for pointing out. I will add support for this for this option to the method tryConsumeAndReturnRemaining, it will work for both, smooth and interval refill. |
The proposed API to specifying interval refill: // 1000 tokens per minute, refill happens with one second interval
Bandwidth limit = Bandwidth.simple(1000, Duration.ofMinutes(1))
.withFixedRefillInterval(Duration.ofSecond(1));
Bucket bucket = Bucket4j.builder()
.addBandwith(limit)
.build(); I am not sure that |
will be released soon |
Thanks for implementing the change, so if i change duration to one minute then refill would happen after one minute, right? // 1000 tokens per minute, refill happens with after 1 minute interval Bucket bucket = Bucket4j.builder() Now in every one minute i would be able to consume only 1000 toke, right? |
right
In general case no, see my previous comment that describes the burst. |
In opposite to smooth refill which adds token as soon as possible, interval refill should regenerate tokens periodically.
Proposed API:
The text was updated successfully, but these errors were encountered: