skip to Main Content

I have a redis cluster created with master slave mode. I want to create a redisson client to access the cluster but I want to specify separate endpoints for reads and writes. Writes should go to master and reads should happen from the slaves. There is a config readMode that can I set to SLAVE to read only from slave nodes but how do I restrict writes to master only?

2

Answers


  1. In Redis, writes happen only in master nodes. So you don’t need separate config to handle that.

    Login or Signup to reply.
  2. There is a config readMode that can I set to SLAVE to read only from slave nodes but how do I restrict writes to master only?

    Writes are executed in master nodes.

    All commands are executed in the master nodes, by default: while Redis Enterprise allows for a multi-master active-active clusters, Redis (Open Source) only allows one master node and zero or more replicas per slot range. In all cases, all nodes can receive both read and write commands but, by default, replicas reply with a -MOVED redirection error along with the endpoint of the master which is believed to handle a given target key. Clients may use that information to contact the master which will actually execute the command.

    With that being said, replicas can be configured to reply to read-only commands – provided they handle the slot range of the given target key. In that context, most cluster-aware Redis clients allow to read from replicas with the goal of distributing the load – with the risk of reading stale data: Redisson manages that through the readMode setting and automatically deals with the aforementioned connection configuration.

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