Skip to content

Commit 05dc252

Browse files
authored
Change default reconnection policy to Exponential (#1896)
Change default reconnection policy to Exponential Update the Exponential policy to take the base as parameter to allow for different growth rates Description: To speed up reconnections, and also avoid reconnection storms, we are changing the default reconnection policy to ExponentialRetry and reducing the deltaBackOff from the previous default of 5s to 2.5s. a This allows more frequent retries early on, when a reconnection is more probable, and less frequent retries later on when it has already been impossible for some time. Another plus for the ExponentialRetry is the additional randomness added to the intervals so that we avoid reconnection storms. Here is a comparison of the two retry policies. ![image](https://user-images.githubusercontent.com/18540925/140260525-dfde3f60-2980-46e9-a0ce-1ac174f2fc80.png) ![image](https://user-images.githubusercontent.com/18540925/140260534-d137d303-e1f8-437e-a4ca-1292b9e89a4f.png) And here is a real world example: ![image](https://user-images.githubusercontent.com/18540925/140263336-cb6b12d7-92ac-4f00-a27c-00fea2d36eaa.png) The randomized exponential (orange) is within the the minimum delta (yellow) and the maximum exponential (gray). The retry happens when the timeout (blue) is greater than the retry limit (orange).
1 parent ccb5f42 commit 05dc252

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

docs/ReleaseNotes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Release Notes
22

33
## Unreleased
4+
- Connection backoff default is now exponential instead of linear (#1896 via lolodi)
45
- Add support for NodeMaintenanceScaleComplete event (handles Redis cluster scaling) (#1902 via NickCraver)
56

67
## 2.2.79

src/StackExchange.Redis/ConfigurationOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ public bool PreserveAsyncOrder
334334
/// <summary>
335335
/// The retry policy to be used for connection reconnects
336336
/// </summary>
337-
public IReconnectRetryPolicy ReconnectRetryPolicy { get { return reconnectRetryPolicy ??= new LinearRetry(ConnectTimeout); } set { reconnectRetryPolicy = value; } }
337+
public IReconnectRetryPolicy ReconnectRetryPolicy { get { return reconnectRetryPolicy ??= new ExponentialRetry(ConnectTimeout/2); } set { reconnectRetryPolicy = value; } }
338338

339339
/// <summary>
340340
/// Indicates whether endpoints should be resolved via DNS before connecting.

0 commit comments

Comments
 (0)