RedissonCluster

RedissonCluster

Minimal cluster configuration requires to contain at least three master nodes. Cluster connection mode activated by follow line:
ClusterServersConfig clusterConfig = config.useClusterServers();

ClusterServersConfig settings listed below:

Cluster settings

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
checkSlotsCoverage
Default value: true

Enables cluster slots check during Redisson startup.

nodeAddresses
Add Redis cluster node address in host:port format. Multiple nodes could be added at once. At least one node from Redis Cluster should be specified.
Redisson discovers automatically cluster topology. Use rediss:// protocol for SSL connection.

scanInterval
Default value: 1000

Redis cluster scan interval in milliseconds.

slots
Default value: 231

Partitions amount used for data partitioning. Data partitioning supported by Set, Map, BitSet, Bloom filter, Spring Cache and Hibernate Cache structures.

This setting is available only in Redisson PRO edition.

readMode
Default value: SLAVE

Set node type used for read operation. Available values:
SLAVE - Read from slave nodes, uses MASTER if no SLAVES are available.
MASTER - Read from master node,
MASTER_SLAVE - Read from master and slave nodes

subscriptionMode
Default value: SLAVE

Set node type used for subscription operation. Available values:
SLAVE - Subscribe to slave nodes,
MASTER - Subscribe to master node,

loadBalancer
Default value: org.redisson.connection.balancer.RoundRobinLoadBalancer

Сonnection load balancer for multiple Redis servers. Available implementations:
org.redisson.connection.balancer.WeightedRoundRobinBalancer
org.redisson.connection.balancer.RoundRobinLoadBalancer
org.redisson.connection.balancer.RandomLoadBalancer

subscriptionConnectionMinimumIdleSize
Default value: 1

Minimum idle connection pool size for subscription (pub/sub) channels. Used by RTopic, RPatternTopic, RLock, RSemaphore, RCountDownLatch, RClusteredLocalCachedMap,
RClusteredLocalCachedMapCache, RLocalCachedMap, RLocalCachedMapCache objects and Hibernate READ_WRITE cache strategy.

subscriptionConnectionPoolSize
Default value: 50

Maximum connection pool size for subscription (pub/sub) channels. Used by RTopic, RPatternTopic, RLock, RSemaphore, RCountDownLatch, RClusteredLocalCachedMap,
RClusteredLocalCachedMapCache, RLocalCachedMap, RLocalCachedMapCache objects and Hibernate READ_WRITE cache strategy

slaveConnectionMinimumIdleSize
Default value: 24

Redis 'slave' node minimum idle connection amount for each slave node.

slaveConnectionPoolSize
Default value: 64

Redis 'slave' node maximum connection pool size for each slave node

masterConnectionMinimumIdleSize
Default value: 24

Redis 'master' node minimum idle connection amount for each slave node. Redisson idle connections are remain for elected slave as master.
Because this node remains in slave connection pool but in non-active state.
These connections are preserved for case when your cluster lost all slaves. In this case master used as slave and idle-connections become in use.

masterConnectionPoolSize
Default value: 24

Redis 'master' node maximum connection pool size

idleConnectionTimeout
Default value: 10000

If pooled connection not used for a timeout time and current connections amount bigger than minimum idle connections pool size, then it will closed and removed from pool. Value in milliseconds.

connectTimeout
Default value: 10000

Timeout in milliseconds during connecting to any Redis server.

timeout
Default value: 3000

Redis server response timeout in milliseconds. Starts to countdown when Redis command was succesfully sent.

retryAttempts
Default value: 3

Error will be thrown if Redis command can't be sended to Redis server after retryAttempts. But if it sent succesfully then timeout will be started.

retryInterval
Default value: 1500

Time interval in milliseconds after which another one attempt to send Redis command will be executed.

password
Default value: null

Password for Redis server authentication.

username
Default value: null

Username for Redis server authentication. Requires Redis 6.0+

subscriptionsPerConnection
Default value: 5

Subscriptions per subscribe connection limit. Used by RTopic, RPatternTopic, RLock, RSemaphore, RCountDownLatch, RClusteredLocalCachedMap,
RClusteredLocalCachedMapCache, RLocalCachedMap, RLocalCachedMapCache objects and Hibernate READ_WRITE cache strategy.

clientName
Default value: null

Name of client connection.

sslEnableEndpointIdentification
Default value: true

Enables SSL endpoint identification during handshaking, which prevents man-in-the-middle attacks.

sslProvider
Default value: JDK

Defines SSL provider (JDK or OPENSSL) used to handle SSL connections. OPENSSL considered as faster implementation and requires netty-tcnative-boringssl-static to be added in classpath.

sslTruststore
Default value: null

Defines path to SSL truststore. It's stores certificates which is used to identify server side of SSL connection.

sslTruststorePassword
Default value: null

Defines password for SSL truststore

sslKeystore
Default value: null

Defines path to SSL keystore. It's stores private key and certificates corresponding to their public keys. Used if server side of SSL connection requires client authentication.

sslKeystorePassword
Default value: null

Defines password for SSL keystore

pingConnectionInterval
Default value: 0

Defines PING command sending interval per connection to Redis. Set 0 to disable.

keepAlive
Default value: false

Enables TCP keepAlive for connection.

tcpNoDelay
Default value: false

Enables TCP noDelay for connection.

natMapper
Default value: no mapper

Defines NAT mapper interface which maps Redis URI object. It's applied to all Redis connections.
There are few implementations: org.redisson.api.HostPortNatMapper and org.redisson.api.HostNatMapper.

Cluster YAML config format

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Below is cluster configuration example in YAML format. All property names matches with ClusterServersConfig and Config object property names.

---
clusterServersConfig:
idleConnectionTimeout: 10000
connectTimeout: 10000
timeout: 3000
retryAttempts: 3
retryInterval: 1500
failedSlaveReconnectionInterval: 3000
failedSlaveCheckInterval: 60000
password: null
subscriptionsPerConnection: 5
clientName: null
loadBalancer: !<org.redisson.connection.balancer.RoundRobinLoadBalancer> {}
subscriptionConnectionMinimumIdleSize: 1
subscriptionConnectionPoolSize: 50
slaveConnectionMinimumIdleSize: 24
slaveConnectionPoolSize: 64
masterConnectionMinimumIdleSize: 24
masterConnectionPoolSize: 64
readMode: "SLAVE"
subscriptionMode: "SLAVE"
nodeAddresses:
- "redis://127.0.0.1:7004"
- "redis://127.0.0.1:7001"
- "redis://127.0.0.1:7000"
scanInterval: 1000
pingConnectionInterval: 0
keepAlive: false
tcpNoDelay: false
threads: 16
nettyThreads: 32
codec: !<org.redisson.codec.FstCodec> {}
transportMode: "NIO"