linagora / james-project

Mirror of Apache James Project
Apache License 2.0
72 stars 62 forks source link

Redis: allow to read from Replicas #5172

Closed quantranhong1999 closed 4 months ago

quantranhong1999 commented 5 months ago

Prerequisites

Better wait for https://github.com/linagora/james-project/issues/5171 to configure master/replica read settings.

Why

By default, Lettuce sends read requests to only master nodes cf https://github.com/redis/lettuce/wiki/ReadFrom-Settings.

Thus we can not leverage read scale using other Replica nodes.

IMO we do not need strong consistency for our Redis use cases (Rate limiting, potentially event bus notifications). We may leverage reading from the Replica nodes for better performance.

How

Introduce in redis.properties smth like:

read.from=MASTER/MASTER_PREFERRED/REPLICA/REPLICA_PREFERRED/LOWEST_LATENCY/ANY/ANY_REPLICA # Default to MASTER?. cf https://github.com/redis/lettuce/wiki/ReadFrom-Settings#read-from-settings

DoD

Tested.

hungphan227 commented 4 months ago

pr https://github.com/apache/james-project/pull/2240

quantranhong1999 commented 4 months ago

Could you apply this to Tmail Redis event bus key too?

hungphan227 commented 4 months ago

Could you apply this to Tmail Redis event bus key too?

maybe another ticket?