Decorrelated jitter does not jitter well
See original GitHub issueSummary: Jitter the retry delays to achieve low concurrency
I’m trying to use the suggested “decorrelated jitter” strategy
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:
- Created 5 years ago
- Reactions:2
- Comments:41 (21 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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.
@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.)