You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update failover docs
- Add migration guide from 6.x to 7.0
- Add instructions on optional deps
- Clean up wording to refer to multiDbClient instead of connection provider
Copy file name to clipboardExpand all lines: docs/failover.md
+69-19Lines changed: 69 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,9 @@
1
1
# Automatic Failover and Failback with Jedis
2
2
3
+
> API was significantly changed in 7.0.0. Please follow the migration guide below.
4
+
>
5
+
> This feature is experimental and may change in future versions.
6
+
3
7
Jedis supports failover and failback for your Redis deployments. This is useful when:
4
8
1. You have more than one Redis deployment. This might include two independent Redis servers or two or more Redis databases replicated across multiple [active-active Redis Enterprise](https://docs.redis.com/latest/rs/databases/active-active/) clusters.
5
9
2. You want your application to connect to and use one deployment at a time.
@@ -24,6 +28,51 @@ The remainder of this guide describes:
24
28
We recommend that you read this guide carefully and understand the configuration settings before enabling Jedis failover
25
29
in production.
26
30
31
+
## Migration from 6.x to 7.x
32
+
33
+
In Jedis 6.x, failover was supported using special constructor for `UnifiedJedis`.
34
+
In Jedis 7.x, failover is supported using `MultiDbClient` and `MultiDbConfig.builder`:
In the configuration here, we've set a sliding window size of 1000 and a failure rate threshold of 50%.
97
147
This means that a failover will be triggered only if both 500 out of any 1000 calls to Redis fail (i.e., the failure rate threshold is reached) and the minimum number of failures is also met.
98
148
99
-
You can now use this `MultiDbClient` instance, and the connection management and failover will be handled transparently.
149
+
You can now use this `MultiDbClient` instance in your application to execute Redis commands.
100
150
101
151
## Configuration options
102
152
103
153
Under the hood, Jedis' failover support relies on [resilience4j](https://resilience4j.readme.io/docs/getting-started),
104
154
a fault-tolerance library that implements [retry](https://resilience4j.readme.io/docs/retry) and [circuit breakers](https://resilience4j.readme.io/docs/circuitbreaker).
105
155
106
-
Once you configure Jedis for failover using the `MultiDbConnectionProvider`, each call to Redis is decorated with a resilience4j retry and circuit breaker.
156
+
Once you configure a `MultiDbClient`, each call to Redis is decorated with a resilience4j retry and circuit breaker.
107
157
108
158
By default, any call that throws a `JedisConnectionException` will be retried up to 3 times.
109
159
If the call fail then the circuit breaker will record a failure.
@@ -136,13 +186,13 @@ For failover, Jedis uses a circuit breaker to detect when a Redis database has f
136
186
Failover configuration is encapsulated in `MultiDbConfig.CircuitBreakerConfig` and can be provided using the `MultiDbConfig.Builder.failureDetector()`.
137
187
Jedis uses the following circuit breaker settings:
| Sliding window size | 2 | The size of the sliding window. Units depend on sliding window type. The size represents seconds. |
142
-
| Threshold min number of failures | 1000 | Minimum number of failures before circuit breaker is tripped. |
143
-
| Failure rate threshold |`10.0f`| Percentage of calls within the sliding window that must fail before the circuit breaker transitions to the `OPEN` state. |
144
-
| Circuit breaker included exception list |[JedisConnectionException]| A list of Throwable classes that count as failures and add to the failure rate. |
145
-
| Circuit breaker ignored exception list | null | A list of Throwable classes to explicitly ignore for failure rate calculations. ||
| Sliding window size | 2 | The size of the sliding window. Units depend on sliding window type. The size represents seconds. |
192
+
| Threshold min number of failures | 1000 | Minimum number of failures before circuit breaker is tripped. |
193
+
| Failure rate threshold |`10.0f`| Percentage of calls within the sliding window that must fail before the circuit breaker transitions to the `OPEN` state. |
194
+
| Circuit breaker included exception list |[JedisConnectionException]| A list of Throwable classes that count as failures and add to the failure rate. |
195
+
| Circuit breaker ignored exception list | null | A list of Throwable classes to explicitly ignore for failure rate calculations. ||
0 commit comments