linagora / james-project

Mirror of Apache James Project
Apache License 2.0
70 stars 63 forks source link

Redis: Support topology discovery for the Master/Replica setup #5171

Closed quantranhong1999 closed 2 months ago

quantranhong1999 commented 2 months ago

Why

Lettuce claims to support Topology Discovery for Redis Cluster and Redis Master/Replica. cf https://lettuce.io/core/release/reference/#masterreplica.standalone-masterreplica

Today our Lettuce only knows either Cluster setup or Standalone setup.

Thus we can not leverage the Master/Replica topology discovery.

How

Suggestion: introduce in redis.properties

redis.topology=cluster/master-slave/standalone. # Default to standalone

DoD

Tested the master/replica topology discovery.

May try to set up a Redis Master/Slave extension if not too complicated. Or at least a manual test. Scenario: Configure the Redis URI to a Replica node. Make sure sending a write command would succeed.

chibenwa commented 2 months ago

That helps our Redis URIs setup be simpler: 1 URI (e.g. 1 K8s service endpoint) should be good enough. No need to manually configure writeServers and readServers for example.

:-1:

If you configure the IP of a signle node:

quantranhong1999 commented 2 months ago

THe best practice in other distibuted technologies is to keep a few seeds for topology discovery, in order to have resiliency on that discovery step.

Sure. We still can declare multiple URIs: https://lettuce.io/core/release/api/io/lettuce/core/masterreplica/MasterReplica.html#connect-io.lettuce.core.RedisClient-io.lettuce.core.codec.RedisCodec-java.lang.Iterable-

hungphan227 commented 2 months ago

Curently when redis.topology=cluster, RedisClusterClient would be used. I have tested RedisClusterClient against master/slave topology and it is still able to detect topology change. I have updated the setting for RedisClusterClient to enable automatic update of topology:

https://github.com/apache/james-project/pull/2229

hungphan227 commented 2 months ago

Previously I was confused between cluster topology and master-replica topology. New PR: https://github.com/apache/james-project/pull/2238