skip to Main Content

In a redis cluster what is the default behaviour for the read operations that happen? Does a client read from the master? I know that a client writes/updates/deletes to the master but what about read operations? If the default behaviour is to read from the master node how can I configure it to read from the slave nodes instead?

2

Answers


  1. The default behavior of replica nodes in cluster-mode enabled clusters
    is to redirect all client read/write requests to an authoritative
    master node of the shard that belongs to the key’s hash slot. The
    replica node serves the read request only if that shard belongs to the
    hash slot and a readonly command was initiated by the client. This
    means that the replica node processes the request only if readonly is
    issued by the client before the request. Otherwise, the request is
    redirected to the primary node of the shard that the hash slot belongs
    to.

    https://aws.amazon.com/premiumsupport/knowledge-center/elasticache-redis-client-readonly/

    Login or Signup to reply.
  2. It all depends on Redis client library. For Jedis/Lettuce, all operations(CRUD) will be send to corresponding master node, and slaves are only used for failover.

    If you wan to implement READONLY slave, you need some customization on Redis client.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search