Help Center/ Distributed Cache Service/ FAQs/ Feature/ Does DCS for Redis Support Read/Write Splitting?
Updated on 2025-05-21 GMT+08:00

Does DCS for Redis Support Read/Write Splitting?

The following table describes DCS's support for read/write splitting.

Instance Type

Read/Write Splitting

Read/write splitting

Supported.

NOTE:

To implement read/write splitting without client configurations, use read/write splitting instances.

Proxy Cluster

By default, read/write splitting is disabled for Proxy Cluster instances, but you can enable it by modifying parameter backend-master-only.

  • By default, read and write requests are allocated to the master node of a Proxy Cluster instance.
  • When read/write splitting is enabled, write requests are allocated to the master node, and read requests are allocated to replica nodes by default. Read requests can also be evenly allocated to the master and replica nodes of a Proxy Cluster.

Redis Cluster

Read/write splitting can be configured and implemented on the client. For details, see Configuration.

Master/Standby Redis 4.0 and later basic

Read/write splitting can be implemented on a client that is able to distinguish between read and write requests.

Other

Not supported.

Configuration

  • To enable read/write splitting for a Proxy Cluster instance, modify parameter backend-master-only from yes (default) to no. For details about how to modify configuration parameters, see Modifying Configuration Parameters of a DCS Instance.
  • For a Redis Cluster instance, you can query all master and replica nodes by running the CLUSTER NODES command. The client will connect to replicas and configure read-only access on them.

    Run the following command to query cluster nodes:

    redis-cli -h {redis_address} -p {redis_port} -a {redis_password} cluster nodes

    Read-only configuration on replicas is achieved through the READONLY command.

  • For a master/standby DCS Redis 4.0 or later basic instance, there are two domain names displayed on the instance details page of the console: a read/write address (master node) and a read-only address (standby node). On the client, you can direct write requests to the read/write domain name and read requests to the read-only domain name.
  • For a read/write splitting instance, read/write splitting is implemented on the server side by default. Proxies distinguish between read and write requests, and forward write requests to the master node and read requests to the standby node. You do not need to perform any configuration on the client.