We have a cluster configuration for Redis used as cache.
Now due to the normal pattern of write to master and read from slave (with other databases), we are trying to do the same thing with Redis cluster.
After some investigation we found that none of the Redis clients (in java) like redisson, jedis and Spring Data Redis support this.
We seem to have found some workaround for it but it seems ugly and now I am thinking if it is worth it?
Here is my use case
With that in mind I have following questions:
Any help (blogs, case study, suggestions) is greatly appreciated.
What is your expectation from slave reads?
It's possible and a usual pattern to read from slaves but it comes with a set of effects.
Quoting from http://redis.io/topics/cluster-spec#scaling-reads-using-slave-nodes:
Normally slave nodes will redirect clients to the authoritative master for the hash slot involved in a given command, however, clients can use slaves in order to scale reads using the
READONLY
command.
READONLY
tells a Redis Cluster slave node that the client is ok reading possibly stale data and is not interested in running write queries.
Jedis has no built-in support to read from other nodes than the master node. Redisson and lettuce provide built-in support for Master and Slave reads. Redisson uses internally a balancer (random, round-robin, weighted) to distribute operations, lettuce provides a preference-driven (Master only, Master preferred, slave, nearest) approach.
Spring Data Redis is built on top of Jedis and lettuce but does not provide a generic feature to read from slaves.
A good rule of thumb is using slaves for availability, not for performance.