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

feat: improve retry backoff jitter #428

Merged
merged 6 commits into from
Nov 15, 2020

Conversation

polvalente
Copy link
Contributor

@polvalente polvalente commented Oct 28, 2020

I noticed that the current backoff uses an uniformily distributed jitter. However, if the random distribution is trully uniform, this means that half of the time the backoff finishes at half the delay it would be expected to finish (e.g. at an attempt with delay 5000ms, it has 50% probability to retry after 2500ms or less). This also introduces the problem that in some other percentage of the time the backoff is actually of linear or constant delay.

This PR refactors the function so the jitter is an additive noise proportional to the current delay, which should keep the backoff at the expected order of magnitude while adding the desired randomness.

A module option is provided to control said random noise level

@teamon teamon merged commit 8ea2fb0 into elixir-tesla:master Nov 15, 2020
@polvalente polvalente deleted the feat/improve-retry-backoff branch November 15, 2020 12:44
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 this pull request may close these issues.

2 participants