-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
How do I use Jitter? Can we add this to the Readme? #4
Comments
Hey @matthawkins90, thanks for opening an issue. I've updated the both the code and the README with information around the jitter functionality. Take a look at: https://github.com/alexdelorenzo/limiter#jitter Note that you'll need to upgrade I'll look into your particular issue and questions when I have some time give them good responses. |
Sounds good, thanks for the quick updates and response. I look forward to your additional feedback. I'm not quite sure how a token-bucket algorithm equates to my goals, but ideally I would be able to say:
In addition to my negative number questions from my initial post, I looked at your code changes and noticed that if |
I'm having a hard time understanding jitter as it relates to my other params.
According to Base,
DEFAULT_JITTER: = False
, and it doesn't seem like DEFAULT_JITTER is ever updated when I call a new Limiter(). I know I can set it as an arg withLimiter(jitter=X)
.I also saw in Base in the definition for
_get_sleep_duration
It's clear that
jitter
can be a bool, int, or float, but I don't really understand how I should size it with respect to myconsume
orrate
values. I don't want to add too much jitter that it ends up overpowering my sleep duration and I end up with a negative number.Let's say I have these params:
rate = 20
# replenish tokens per secondconsume = 1
# because I want my function to be allowed to run a maximum of 20 times per secondcapacity = 300
# because I want my function to be able to run for 15 seconds maximum before it gets limited (function can't get called more than 300 times per minute max)But according to the _get_sleep_duration calculation, my
duration = (1 - 300) / 20 = -14.95
and so I'm already at a negative number.The text was updated successfully, but these errors were encountered: