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 and jitter for retries #204

Merged
merged 3 commits into from
Feb 10, 2024
Merged

Conversation

acm19
Copy link
Contributor

@acm19 acm19 commented Jan 2, 2024

Adds exponential backoff by multiplying the retryTimeoutMs by 2^attempt. Adds a random jitter to spread out the retries. Although in the initial implementation the retry function isn't available to the user the code is written in a way that makes it easier to change that.

Refactors the tests to avoid using Thread#sleep, which is not only a bad practice producing not deterministic tests but also makes them very slow. A reduction of more that 90% of testing time is percieved for the tests where this was changed.

Resolves: #194

@acm19 acm19 force-pushed the main branch 3 times, most recently from 1d4284d to ccfdd0a Compare January 2, 2024 11:26
Copy link
Contributor

@nehaev nehaev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution @acm19!

Overall the PR looks good. However, comments need to be addressed.

@acm19 acm19 force-pushed the main branch 8 times, most recently from 382544d to ddd8577 Compare January 17, 2024 16:07
@acm19 acm19 force-pushed the main branch 7 times, most recently from e2bb1ad to 5ea1179 Compare January 31, 2024 16:16
@acm19 acm19 marked this pull request as draft January 31, 2024 16:16
@acm19 acm19 force-pushed the main branch 8 times, most recently from 99e26e4 to 783308b Compare February 1, 2024 11:48
@acm19 acm19 force-pushed the main branch 3 times, most recently from ee2f708 to e721420 Compare February 1, 2024 15:03
@acm19 acm19 marked this pull request as ready for review February 1, 2024 15:28
@acm19 acm19 requested a review from nehaev February 1, 2024 15:29
Adds exponential backoff by multiplying the `retryTimeoutMs` by
`2^attempt`. Adds a random jitter to spread out the retries. Although
in the initial implementation the retry function isn't available to the
user the code is written in a way that makes it easier to change that.

Refactors the tests to avoid using `Thread#sleep`, which is not only a
bad practice producing not deterministic tests but also makes them very
slow. A reduction of more that 90% of testing time is percieved for the
tests where this was changed.

Resolves: loki4j#194
@nehaev
Copy link
Contributor

nehaev commented Feb 10, 2024

Looks good! Thank you @acm19!

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.

Add exponential backoff and jitter to the retries
2 participants