question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Decorrelated jitter does not jitter well

See original GitHub issue

Summary: Jitter the retry delays to achieve low concurrency



I’m trying to use the suggested “decorrelated jitter” strategy

jittering

In my experiment, the suggested decorrelated jitter does not achieve what it supposed to.

First, new Random() is not quite random, when it comes to reducing concurrency. You can get multiple instances with the same seed, if many retries are issued simultaneously.

Following code achieves much lower concurrency and better distribution. In the attached screenshot you can see that the ‘advanced’ graph has much lower maximum and smoother distribution, which is highly desired to avoid concurrency spikes.

IEnumerable<TimeSpan> DecorrelatedExponent()
{
    var r = new Random(Guid.NewGuid().GetHashCode());
    for (var softAttemptCount = 0.0; softAttemptCount < 4; ) {
        softAttemptCount += r.NextDouble() * 2;
        yield return TimeSpan.FromSeconds(
            Math.Pow(2, softAttemptCount) * random.NextDouble());
    }
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:41 (21 by maintainers)

github_iconTop GitHub Comments

2reactions
george-polevoycommented, Nov 20, 2018

@reisenberger Algorithm by AWS also has a flaw. On my graphs it looks smoother, but still has spikes, because it’s not truly decorrelated.

@grant-d The problem with clamping using Min Max is that it ruins randomness, flooding the distribution with some constants. As for the API guarantees, you can use math to proof the MAX and MIN. For ex. max recovery interval for retry is a sum of geometric progression, not matter if you randomize inside, if only limited range random variable does not participate in any asymptotic math function such as 1/x.

My graphing framework turned to be very useful to analyze the problem. I will share it as I promised as I clean up the code.

Currently busy preparing for my DotNext talk this week. I will follow up next week. I’ve put substantial effort into exploring this, and I will make sure we use strong math and also we will have good visual proof of what’s happening in our formulas.

1reaction
reisenbergercommented, Aug 29, 2019

@george-polevoy Are you happy if we include your ‘soft exp, soft delay X’ algorithm in the Polly.Contrib.WaitAndRetry repo? (We can do all the necessary work to move the code there.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exponential Backoff And Jitter | AWS Architecture Blog
It does slightly more work than “Full Jitter”, and takes much longer. The decision between “Decorrelated Jitter” and “Full Jitter” is less clear ......
Read more >
Exponential Back off with Jitter
Decorrelated jitter is a technique used to introduce a small amount of variability into the timing of API requests. Rather than sending requests...
Read more >
Better Retries with Exponential Backoff and Jitter
In this tutorial, we'll explore how we can improve client retries with two different strategies: exponential backoff and jitter.
Read more >
Why is random jitter applied to back-off strategies?
It smooths traffic on the resource being requested. If your request fails at a particular time, there's a good chance other requests are...
Read more >
Use exponential backoff with jitter and/or tune its parameters
I'm going to start by summarizing my comparison of the algorithms. The existing algorithm is a weird hybrid of decorrelated jitter and equal ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found