-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
common.Backoff now implements jitter instead of sleeping for a fixed amount of time #10177
Conversation
da6225f
to
3f8f06e
Compare
@urso I've added the new interface and move any reference of *common.Backoff to use that interface, I haven't made it configurable by the user for this we probably want a bigger discussion so for now I left it to the implementer. Currently, Redis and output/backoff will now use the EqualJitterBackoff strategy as the default. This mean that the default pipeline, the monitoring pipeline or any user of Redis will now have some random in it. @kvch Journalbeat will now use the interface instead of the type for the backoff field but will still use the ExpBackoff strategy. |
Note: I have added a minimal test suite for both the implementation that tests:
|
This PR add a new interface called backoff.Backoff, this can be used to generalize any backoff interaction. It move the current Backoff strategy under an ExpBackoff type. ExpBackoff times is the same as before on every wait we just exponentially increase the duration of the wait and sleep for that amount. EqualJitterBackoff uses an exponential increment of the duration but will take half of that value as a fixed sleep time and the other half as a jitter. This will help distribute the new request when a cluster is done instead of having all the beats trying to reconnect at once. The Redis implementations and any clients wrapped with a backoff will now use the EqualJitterBackoff, any other code will keep using the same exponential strategy. Fixes: elastic#10172
3f8f06e
to
5d7864b
Compare
@urso Also this is not a full jitter, more like an EqualJitter in that case, this ensures that the connection will at least sleep a period of time before retrying again, looking at the numbers from the article they look pretty similar with the rates. |
b.duration *= 2 | ||
if b.duration > b.max { | ||
b.duration = b.max | ||
} |
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.
nit: By moving this block before the computation of temp
you don't need the init*2
on reset. In the end it doesn't matter :)
Let's merge into 6.6 and 6.x |
…amount of time (elastic#10177) This PR add a new interface called backoff.Backoff, this can be used to generalize any backoff interaction. It move the current Backoff strategy under an ExpBackoff type. ExpBackoff is the same as before on every wait we just exponentially increase the duration of the wait and sleep for that amount. EqualJitterBackoff uses an exponential increment of the duration but will take half of that value as fixed sleep time and the other half as a jitter. This will help distribute the new request when a cluster is done instead of having all the beats trying to reconnect at once. The Redis implementations and any clients wrapped with a backoff will now use the EqualJitterBackoff, any other code will keep using the same exponential strategy. Fixes: elastic#10172 (cherry picked from commit 4cb9bd7)
…amount of time (elastic#10177) This PR add a new interface called backoff.Backoff, this can be used to generalize any backoff interaction. It move the current Backoff strategy under an ExpBackoff type. ExpBackoff is the same as before on every wait we just exponentially increase the duration of the wait and sleep for that amount. EqualJitterBackoff uses an exponential increment of the duration but will take half of that value as fixed sleep time and the other half as a jitter. This will help distribute the new request when a cluster is done instead of having all the beats trying to reconnect at once. The Redis implementations and any clients wrapped with a backoff will now use the EqualJitterBackoff, any other code will keep using the same exponential strategy. Fixes: elastic#10172 (cherry picked from commit 4cb9bd7)
…ad of sleeping for a fixed amount of time (#10229) Cherry-pick of PR #10177 to 6.x branch. Original message: This PR add a new interface called backoff.Backoff, this can be used to generalize any backoff interaction. It move the current Backoff strategy under an ExpBackoff type. ExpBackoff is the same as before on every wait we just exponentially increase the duration of the wait and sleep for that amount. EqualJitterBackoff uses an exponential increment of the duration but will take half of that value as fixed sleep time and the other half as a jitter. This will help distribute the new request when a cluster is done instead of having all the beats trying to reconnect at once. The Redis implementations and any clients wrapped with a backoff will now use the EqualJitterBackoff, any other code will keep using the same exponential strategy. Fixes: #10172
…amount of time (#10177) (#10230) This PR add a new interface called backoff.Backoff, this can be used to generalize any backoff interaction. It move the current Backoff strategy under an ExpBackoff type. ExpBackoff is the same as before on every wait we just exponentially increase the duration of the wait and sleep for that amount. EqualJitterBackoff uses an exponential increment of the duration but will take half of that value as fixed sleep time and the other half as a jitter. This will help distribute the new request when a cluster is done instead of having all the beats trying to reconnect at once. The Redis implementations and any clients wrapped with a backoff will now use the EqualJitterBackoff, any other code will keep using the same exponential strategy. Fixes: #10172 (cherry picked from commit 4cb9bd7)
…amount of time (elastic#10177) This PR add a new interface called backoff.Backoff, this can be used to generalize any backoff interaction. It move the current Backoff strategy under an ExpBackoff type. ExpBackoff is the same as before on every wait we just exponentially increase the duration of the wait and sleep for that amount. EqualJitterBackoff uses an exponential increment of the duration but will take half of that value as fixed sleep time and the other half as a jitter. This will help distribute the new request when a cluster is done instead of having all the beats trying to reconnect at once. The Redis implementations and any clients wrapped with a backoff will now use the EqualJitterBackoff, any other code will keep using the same exponential strategy. Fixes: elastic#10172
…r instead of sleeping for a fixed amount of time (elastic#10229) Cherry-pick of PR elastic#10177 to 6.x branch. Original message: This PR add a new interface called backoff.Backoff, this can be used to generalize any backoff interaction. It move the current Backoff strategy under an ExpBackoff type. ExpBackoff is the same as before on every wait we just exponentially increase the duration of the wait and sleep for that amount. EqualJitterBackoff uses an exponential increment of the duration but will take half of that value as fixed sleep time and the other half as a jitter. This will help distribute the new request when a cluster is done instead of having all the beats trying to reconnect at once. The Redis implementations and any clients wrapped with a backoff will now use the EqualJitterBackoff, any other code will keep using the same exponential strategy. Fixes: elastic#10172
…amount of time (elastic#10177) (elastic#10230) This PR add a new interface called backoff.Backoff, this can be used to generalize any backoff interaction. It move the current Backoff strategy under an ExpBackoff type. ExpBackoff is the same as before on every wait we just exponentially increase the duration of the wait and sleep for that amount. EqualJitterBackoff uses an exponential increment of the duration but will take half of that value as fixed sleep time and the other half as a jitter. This will help distribute the new request when a cluster is done instead of having all the beats trying to reconnect at once. The Redis implementations and any clients wrapped with a backoff will now use the EqualJitterBackoff, any other code will keep using the same exponential strategy. Fixes: elastic#10172 (cherry picked from commit 7e68306)
This PR add a new interface called backoff.Backoff, this can be used to
generalize any backoff interaction. It move the current Backoff strategy
under an ExpBackoff type.
ExpBackoff is the same as before on every wait we just
exponentially increase the duration of the wait and sleep for that
amount.
EqualJitterBackoff uses an exponential increment of the duration but
will take half of that value as fixed sleep time and the other half
as a jitter. This will help distribute the new request when a cluster is
done instead of having all the beats trying to reconnect at once.
The Redis implementations and any clients wrapped with a backoff will
now use the EqualJitterBackoff, any other code will keep using the same
exponential strategy.
Fixes: #10172