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
[HttpClient] Add jitter to RetryBackoff #38434
Conversation
If I understand this feature, when using 1000ms and a multiplier of 3, instead of waiting this:
It would wait something like this:
I can't understand why the second is best for the server or for the local application. Thanks. |
When several clients perform the same request at the same time (ie. started by a crontab) they all call the server at the exact same time, and have a highest probability to trigger an error then they all retries at the exact same time. More documentation here https://aws.amazon.com/builders-library/timeouts-retries-and-backoff-with-jitter/?did=ba_card&trk=ba_card and here https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/ |
@javiereguiluz if you are the only client, the jitter has indeed no value. The value appears when multiple clients apply such jitter: Without jitter:
With jitter:
|
Thanks for the comments ... but isn't a bit unlikely that your app starts more than one HTTP client making requests to the same server at the exact same time? I'm probably missing something, because I like this idea in theory but I don't say any significant difference in practice. But I guess some folks using Symfony will fit this scenario so they'll like the new feature. Thanks! |
@javiereguiluz This can happen trivially when making concurrent requests to a rate-limited endpoint (eg the github API). |
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.
what about retry-after headers?
also, do we care about the order at all?
yeah, I wondered if it should bellongs to On the other hand, the server provide the |
there is not even a need for both clients to be part of the same app. |
and indeed, |
Thank you @jderusse. |
From the idea https://twitter.com/mtdowling/status/1313205613158043648 this PR adds a new
jitter
parameter to the ExponentialBackOff implementation.jitter is a percentage (float between 0 and 1) of randomness to apply to the computed delay.
ie. if the initial delay is 1000ms, and jitter=0.2, the finale delay will be an number between 800 and 1200 (1000 +/- 20%)