Skip to content
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

Recoverability Delayed retry TimeIncrease formula should be easily overridable to do exponential retry and/or add jitter #5012

Closed
ramonsmits opened this issue Oct 9, 2017 · 3 comments

Comments

@ramonsmits
Copy link
Member

ramonsmits commented Oct 9, 2017

Current API:

cfg.Recoverability()
    .Delayed(c =>
    {
        c.NumberOfRetries(5);
        c.TimeIncrease(TimeSpan.FromSeconds(5));
    });

This does not result in exponential backoff which is often used for retries. By adding an optional lambda we give customers an easy way to calculate an increment/exponential/random delay.

Exponential backoff based on the previous delay:

c.TimeIncrease(TimeSpan.FromSeconds(2), delay => TimeSpan.FromSeconds(Math.Pow(delay.TotalSeconds(), 2)));

Exponential backoff based on the previous delay including randomized jitter:

var r = new Random();
c.TimeIncrease(TimeSpan.FromSeconds(2), delay =>
{
    double jitter;
    lock (r) jitter = r.NextDouble();
    jitter *= 0.2; // max 20%
    return TimeSpan.FromSeconds(Math.Pow(delay.TotalSeconds, 2 + jitter));
});
@timbussmann
Copy link
Contributor

I think a custom recoverability policy would cover this requirement: https://docs.particular.net/nservicebus/recoverability/custom-recoverability-policy ?

@timbussmann
Copy link
Contributor

ping @ramonsmits
given the ability to use custom recoverability policies, do you still think this is an issue we need to look into further?

@timbussmann
Copy link
Contributor

I'm going to close this issue for now as @Particular/nservicebus-maintainers think this is an edge case which we don't see as part of the standard API currently. The custom recoverability policy API does allow much more flexibility in implementing custom recoverability behaviors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants