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

Default retry strategy uses exponential backoff and jitter #1854

Closed

Conversation

qsymmachus
Copy link

@qsymmachus qsymmachus commented Feb 2, 2024

The current default retry strategy increases delay linearly with no jitter. This can lead to a thundering herd problem if many clients lose their connection at once, which is common during events like a Redis upgrade.

A retry strategy that uses exponential backoff plus a random jitter helps mitigate this risk and is recommended in many best practices documents for Redis clients, so I propose making this the default.

The default strategy I implemented will do the following:

  • Delay will be equal to (n^2) * 50 ms where n is the current retry count, with a maximum value of 2000 ms.
  • Jitter is a random value between 0 and 200 ms.

The millisecond values I choose are somewhat arbitrary, and I'm happy to change them if we think they're not right.

Both are recommended parts of client retry strategies to prevent
thundering herd problems when many clients lose their connection at once
(for example, during a Redis upgrade).
@qsymmachus
Copy link
Author

I light of #1870, which suggests that node-redis should be favored over this package, I'm closing this and opening redis/node-redis#2736

@qsymmachus qsymmachus closed this Apr 5, 2024
@qsymmachus qsymmachus deleted the retry-default-with-backoff-jitter branch April 5, 2024 20:01
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.

None yet

3 participants