Redisson Replcated Mode

Redisson Replcated Mode

Replicated mode could be used with any hosting.
Replicated connection mode activated by follow line:

ReplicatedServersConfig replicatedConfig = config.useReplicatedServers();

Replicated ServersConfig settings listed below:

Replicated Programmatic config:

Config config = new Config();
config.useReplicatedServers()
.setScanInterval(2000) // master node change scan interval
// use “rediss://“ for SSL connection
.addNodeAddress(“redis://127.0.0.1:7000”, “redis://127.0.0.1:7001”)
.addNodeAddress(“redis://127.0.0.1:7002”);

RedissonClient redisson = Redisson.create(config);

Replicated settings:

nodeAddresses
Add Redis node address in host:port format. Multiple nodes could be added at once. All nodes (master and slaves) should be defined. Use rediss:// protocol for SSL connection.

scanInterval
Default value: 1000

Replicated node scan interval in milliseconds.

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

dnsMonitoringInterval
Default value: 5000

Interval in milliseconds to check the endpoint’s DNS. Applications must ensure the JVM DNS cache TTL is low enough to support this. Set -1 to disable.

subscriptionConnectionMinimumIdleSize
Default value: 1

Redis ‘slave’ node minimum idle subscription (pub/sub) connection amount for each slave node

subscriptionConnectionPoolSize
Default value: 50

Redis ‘slave’ node maximum subscription (pub/sub) connection pool size for each slave node

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: 64

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.

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: MASTER

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

connectTimeout
Default value: 10000

Timeout during connecting to any Redis server.

timeout
Default value: 3000

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

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 after which another one attempt to send Redis command will be executed. Value in milliseconds.

failedSlaveReconnectionInterval
Default value: 3000

Interval of Redis Slave reconnection attempt when it was excluded from internal list of available servers.
On each timeout event Redisson tries to connect to disconnected Redis server. Value in milliseconds.

failedSlaveCheckInterval
Default value: 60000

Redis Slave node failing to execute commands is excluded from the internal list of available nodes when the time interval
from the moment of first Redis command execution failure on this server reaches defined value. Value in milliseconds.

database
Default value: 0

Database index used for Redis connection

password
Default value: null

Password for Redis server authentication.

subscriptionsPerConnection
Default value: 5

Subscriptions per Redis connection limit

clientName
Default value: null

Name of client connection

sslEnableEndpointIdentification
Default value: true

Enables SSL endpoint identification.

sslProvider
Default value: JDK

Defines SSL provider (JDK or OPENSSL) used to handle SSL connections.

sslTruststore
Default value: null

Defines path to SSL truststore

sslTruststorePassword
Default value: null

Defines password for SSL truststore

sslKeystore
Default value: null

Defines path to SSL keystore

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.

Replicated YAML config format:

Below is replicated configuration example in YAML format.
All property names matches with ReplicatedServersConfig and Config object property names.


replicatedServersConfig:
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:2812”
  • “redis://127.0.0.1:2815”
  • “redis://127.0.0.1:2813”
    scanInterval: 1000
    threads: 16
    nettyThreads: 32
    codec: !<org.redisson.codec.FstCodec> {}
    transportMode: “NIO”