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

I'm pretty sure this is supposed to be exponential #4

Open
wparad opened this issue Mar 9, 2022 · 7 comments · May be fixed by #6
Open

I'm pretty sure this is supposed to be exponential #4

wparad opened this issue Mar 9, 2022 · 7 comments · May be fixed by #6

Comments

@wparad
Copy link

wparad commented Mar 9, 2022

But here is it multiplicative. Reason and experimentation suggests the formula for the Nth time is:

delay wait = interval Seconds * (backoff rate) ^ (attempt - 1)

image

But we would expect for the 4 attempts to be

> 30 * 5 ** 0
30
> 30 * 5 ** 1
150
> 30 * 5 ** 2
750
> 30 * 5 ** 3
3750

See similar here: https://exponentialbackoffcalculator.com/

@JesterXL
Copy link
Owner

JesterXL commented Mar 9, 2022

@wparad Thanks, I'll take a look.

@wparad
Copy link
Author

wparad commented Mar 9, 2022

fwiw, I spent a really long time on not finding any good documented cases on how this works, so it might be valuable to actually run a state machine with the exact configuration to see what the times end up being.

@JesterXL
Copy link
Owner

JesterXL commented Mar 9, 2022

Good idea, I'll create some tests with results to see.

@sacredwolf7
Copy link

The logic should be like:
(Interval)* Math.pow(backOff, attempt);

@cameroncf
Copy link

I just spent more time than I'd like to matching up math to actual results in a Step Function that failed a few times and here is the logic that I came up with:

previousTime + ((Interval)* Math.pow(backOff, attempt));

I validate that it matches results where:

backoffRate: 3,
interval: Duration.seconds(10),
maxAttempts: 5,

Which yields this result:

0+10*(3^0) = 10
10+(10*(3^1)) = 40
40+(10*(3^2)) = 130
130+(10*(3^3)) = 400
400+(10*(3^4)) = 1210

@cameroncf
Copy link

cameroncf commented Jul 20, 2023

@JesterXL I forked the repo and attempted to make this change but I don't know enough Elm to do it quickly. Would love to help get this calculator working though. It's really the only thing I've found via Google that can do this sort of calculation (even if it's a bit off right now).

@cameroncf
Copy link

cameroncf commented Jul 25, 2023

I'm knee deep in Step Functions this week so I'm going to add more test data here so we know what the math and results should looks like.

I built a test function that will intentionally fail since it's trying to hit a DynamoDB table that doesn't exist.

a

Ran it, and got the following times:

b

The right math is Interval * (backOff ^ retryCount).

PR inbound shortly.

@cameroncf cameroncf linked a pull request Jul 25, 2023 that will close this issue
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

Successfully merging a pull request may close this issue.

4 participants