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

Add exponential backoff with jitter #31

Merged
merged 1 commit into from
Mar 9, 2019
Merged

Add exponential backoff with jitter #31

merged 1 commit into from
Mar 9, 2019

Conversation

mononym
Copy link
Contributor

@mononym mononym commented Mar 6, 2019

This is a more dynamic and smooth backoff strategy than a simple exponential or even exponential piped through the randomizer, both of which will create groupings of calls at certain points in time.

See the link provided in the documentation for the function for more detailed info on the algorithm and effects.

@safwank
Copy link
Owner

safwank commented Mar 9, 2019

Thanks for the PR @mononym. I'm wondering if it makes more sense to introduce a new function jitter/1 (similar to randomize/2) to which you can pipe a stream of exponential delays, e.g.

def jitter(delays) do
  Stream.map(delays, fn d ->
    :rand.uniform(trunc(d))
  end)
end

That way the randomization function is decoupled from the exponentiation function to preserve their composability.

What do you reckon?

@safwank safwank self-assigned this Mar 9, 2019
@mononym
Copy link
Contributor Author

mononym commented Mar 9, 2019

Should work just fine. Made the adjustment.

@safwank safwank merged commit 4a2686f into safwank:master Mar 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants