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

Figure out token bucket details #6

Open
njsmith opened this issue Oct 7, 2018 · 0 comments
Open

Figure out token bucket details #6

njsmith opened this issue Oct 7, 2018 · 0 comments

Comments

@njsmith
Copy link
Member

njsmith commented Oct 7, 2018

Should there be an initial burst? Or an option to control that?

On the one hand, if you assume that we're starting from a blank slate, where everything's been idle infinitely far in the past, then it makes sense to start out the bucket with the full max_burst tokens in it.

On the other hand, if we assume that we have no idea about the past, and maybe some other process or call or something might have used up our quota just before this call started, then the conservative thing to do is to start the bucket with 0 tokens. This is the only way to guarantee that we don't exceed the max_per_second limit over the course of a call.

Right now what we do is start the bucket with 1 token, which is hard to justify theoretically! But it means that we immediately kick off the first task, and then makes the next task wait (1/max_per_second) seconds to start, which is possibly what people would naively expect...

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

1 participant