redis / ioredis

🚀 A robust, performance-focused, and full-featured Redis client for Node.js.
MIT License
14.06k stars 1.19k forks source link

Default retry strategy uses exponential backoff and jitter #1854

Closed qsymmachus closed 3 months ago

qsymmachus commented 5 months ago

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:

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

qsymmachus commented 3 months ago

I light of https://github.com/redis/ioredis/issues/1870, which suggests that node-redis should be favored over this package, I'm closing this and opening https://github.com/redis/node-redis/pull/2736