-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 some randomness to the exponential backoff of max_retries #1336
Comments
👍 |
I'd be in favor of adding jitter to the retry backoff. Feel free to send a PR. |
And appart of adding jitter, what do you think about changing the shape of the function to use a sigmoid one: I propose sigmoid because this exponential backoff becomes useless, as the back off time is too exagerated when we get into 8 or more retries. With a sigmoid function the back off time will converge to a maximum time to backoff. Unfortunatelly this is a major change, specially for common retry numbers, that might break tools that use this library. |
I think you're right that a fundamental change to the algorithm as a default might be an issue (though it might not), we might be able to expose that in other ways. You can, of course, already bring your own backoff block. |
Added to feature request backlog. Will definitely take as a PR as well. |
jitter functions, max delay cap, configurable base delay
The retry logic configured by
max_retries
, for the case of Rate limit related errors, does a exponential backoff following this function:2.0 ** retries * 0.3
That is great, but there is a problem: It is exactly the same backoff time for every execution. This is problematic when you are doing lots of operations from multiple threads. For instance, creating a environment with multiple VMs using 32 threads. All the threads will execute the same API calls at the same time, and if several threads fail at the same time because the Rate limit from AWS, they will retry again after the same amount of seconds.
What I want to propose is add a little bit of randomness to that backoff. We can use this function:
With this code we can test it a little bit:
What do you think?
If you agree, I can do a PR.
The text was updated successfully, but these errors were encountered: