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
feat: Exponential backoff factor for HTTP request retries #3358
Conversation
@fselmo as per this issue #3210 |
Hey @hr98w. Thanks for getting this started. I'm not sure that we need to add yet another configuration option here. If we make the sleep time itself exponential, the backoff factor can apply directly to that. Something like: for i in range(self.exception_retry_configuration.retries):
try:
return make_post_request(
self.endpoint_uri, request_data, **self.get_request_kwargs()
)
except tuple(self.exception_retry_configuration.errors) as e:
if i < self.exception_retry_configuration.retries - 1:
time.sleep(
# the `backoff_factor` works as a factor on the inherent
# exponential setup of 2**i
self.exception_retry_configuration.backoff_factor * 2**i
)
continue
else:
raise e
return None Thoughts on that? |
@fselmo sure, this also works. I introduced a new variable to let users determine the exponential factor. Keeping that factor as 1 means no exponenial backoff. We can keep it simple here, will follow your advice. |
I hear you. That would allow for more configuration for sure. Exponential is pretty standard and keeping that factor low still allows for pretty quick succession if desired. If you're good with my simpler approach then let's go for it 👍🏼 |
We should maybe decrease the default value here to |
Starting from 0.5 seems too large for me. But i'm not sure for JSON-RPC calls, any latency stats you can share? |
@fselmo Updated the PR, please help review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With a few tweaks to the wording this LGTM. I gave some suggestions to the wording. The important thing here is clarity and I don't think we need to be super technical in the documentation description since we can conceptually describe the doubling strategy. The technical details can be sniffed out by a curious user if they'd like to see the implementation. I'd love your thoughts on it though. Thanks again for getting the ball rolling on this... this is one of the final pieces for getting v7
wrapped up 👍🏼
@fselmo Thanks for your comment! Got your point to make it easy to understand. Resolved them. |
…iders. - update docs - decrease default backoff - fix lint - add newsfragment
Thanks again 👍🏼 |
What was wrong?
Related to Issue #3210
How was it fixed?
Make the backoff_factor for the ExceptionRetryConfiguration class work as an actual exponential "backoff factor" And Update the doc.
Reuse
backoff_factor
as the initial back off timeIntroduce a new field
exponential_factor
Todo:
Cute Animal Picture