-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Implement jitter in @Retryable to avoid thundering herd #11805
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
Implement jitter in @Retryable to avoid thundering herd #11805
Conversation
* @return The jitter factor used to apply random deviation to retry delays | ||
*/ | ||
@Digits(integer = 1, fraction = 2) | ||
String jitter() default "0.25"; |
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.
String jitter() default "0.25"; | |
String jitter() default "0.0"; |
should be set default jitter to 0
? (jitter 0
means don't apply jitter by default)
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.
That's a valid point. Thank you for the suggestion!
@@ -173,6 +187,10 @@ public Class<? extends Throwable> getCapturedException() { | |||
public long nextDelay() { | |||
double multiplier = getMultiplier().orElse(1.0); | |||
long delay = (long) ((getDelay().toMillis()) * pow(multiplier, attemptNumber.get() - 1)); | |||
double jitter = getJitter().orElse(0); | |||
if(jitter > 0) { |
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.
if(jitter > 0) { | |
if (jitter > 0) { |
nit. indent
/** | ||
* @return The jitter factor used to apply random deviation to retry delays | ||
*/ | ||
OptionalDouble getJitter(); |
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.
needs default impl
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.
Thanks for the feedback! I've updated the PR to include the default implementation.
I'd appreciate any further comments you might have.
Thanks for the contribution! |
This PR introduces a jitter parameter to the
@Retryable
annotation, as requested in issue #11631.Closes #11631