Skip to content
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

Changing rate on the fly #4

Open
simon-whitehead opened this issue Apr 9, 2015 · 1 comment
Open

Changing rate on the fly #4

simon-whitehead opened this issue Apr 9, 2015 · 1 comment

Comments

@simon-whitehead
Copy link

Hello,

I'll be honest - my attempt at this was quite unsuccessful as I am not sure I understand the algorithm 100% .. so I'm creating an issue to get your thoughts.

I would like to change the rate dynamically. I added a SetRate method to the bucket that basically creates and sets a new fillInterval and quantum.. but clearly this is incorrect as the speed of the bucket becomes exponentially slower until it eventually hits zero and stops completely.

Any advice?

Cheers,

Simon

@rogpeppe
Copy link
Contributor

[Sorry for outrageously tardy response to this issue - I've just fixed my github notifications so I don't lose everything!]

Changing the rate dynamically is hard the way that the algorithm works. I'm not sure it actually can work, because if something is already waiting for free tokens and the rate changes, there's nothing that can make it change the amount of time it's already indented to sleep for.

I'd suggest that creating a new token bucket with the different rate might be another possible solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants