Tair(Redis OSS-compatible) introduces the read/write splitting architecture to handle read-heavy workloads. This architecture offers a high level of availability, performance, and flexibility in delivering read/write splitting services. This architecture allows a large number of clients to concurrently read hot data from read replicas. Additionally, read/write splitting instances use the proxy component developed by the Alibaba Cloud Tair team to provide services such as data distribution and failover. This reduces O&M costs.
Components
A read/write splitting instance contains a master node, multiple read replicas, multiple proxy nodes, and a high availability (HA) system.
Component | Cloud-native read/write splitting architecture (recommended) | Classic read/write splitting architecture |
Master node | The master node processes all write requests. It also processes specific read requests together with read replicas. | |
Read replica | Read replicas handle read requests and have the following benefits:
| Read replicas handle read requests and have the following benefits:
|
Replica node | No replica nodes are provided. Read replicas are used as replica nodes. If the master node fails, requests are switched to a random read replica. Cloud-native read/write splitting instances cost less than classic read/write splitting instances that have the same specifications because of the lack of replica nodes. | A replica node serves as a cold standby node to back up data and does not provide services. If the master node fails, requests are switched to the replica node. |
Proxy node | When a client is connected to a proxy node, the proxy node automatically identifies the type of request initiated by the client and then distributes the traffic based on predefined weights assigned to each data node. In a typical configuration, all data nodes have equal weights, and you cannot change the weights. For example, write requests are forwarded to the master node, and read requests are forwarded to the master node and read replicas. Note
| |
HA system | The HA system monitors the status of each node. If the master node fails, the HA system performs a switchover between the master node and the replica node. If a read replica fails, the HA system creates another read replica to process read requests. During a switchover, the HA system updates the routing and weight information. |
Benefits
Compatibility
You can upgrade standard instances to read/write splitting instances that use proxy nodes to forward requests. After the upgrade, you can connect to the instances from any Redis clients without modifying your application. Read/write splitting instances are fully compatible with Redis commands. For information about the limits on commands supported by read/write splitting instances, see Limits on commands supported by read/write splitting instances.
HA system
Alibaba Cloud has developed an HA system for read/write splitting instances. The HA system monitors the status of all nodes of an instance to ensure HA. If the master node fails, the HA system switches the workloads from the master node to the replica node and updates the instance topology. If a read replica fails, the HA system creates another read replica. The HA system synchronizes data, forwards read requests to the new read replica, and suspends the faulty read replica.
A proxy node monitors the status of each read replica in real time. If a read replica is unavailable due to an exception, the proxy node reduces the weight of this read replica. If a read replica fails to be connected for a specified number of times, the system suspends the read replica and forwards read requests to available read replicas. The proxy node continues to monitor the status of the unavailable read replica. After the read replica recovers, the proxy node adds it to the list of available read replicas and forwards requests to it.
High performance
The read/write splitting architecture supports chained replication. This allows you to scale out read replicas to increase the read capacity. The replication process is optimized based on the Redis source code to maximize workload stability during replication and make full use of the physical resources for each read replica.
Scenarios
High queries per second (QPS)
The standard architecture of ApsaraDB for Redis is not designed for high QPS scenarios. If your application is read-heavy, you can select a read/write splitting instance and deploy multiple read replicas to resolve performance bottlenecks caused by the single-node standard architecture. A read/write splitting instance can handle QPS that is up to nine times that of a standard instance.
Latency exists when data is synchronized to read replicas. Therefore, read/write splitting instances are suitable for applications that can tolerate a specific amount of dirty data. In scenarios that require high data consistency, we recommend that you choose the cluster architecture.
Usage notes
If a read replica fails, requests are forwarded to other available read replicas. If all read replicas are unavailable, requests are forwarded to the master node. Read replica failures may result in increased workloads on the master node and prolonged response time. To process a large number of read requests, we recommend that you use multiple read replicas.
If an error occurs on a read replica, the HA system suspends the read replica and creates another read replica. This process involves resource allocation, data synchronization, and service loading. The amount of time that is required for a switchover depends on the system workloads and data volume. ApsaraDB for Redis does not guarantee a specific amount of time required for data restoration by using read replicas.
Full data synchronization among read replicas is triggered in specific scenarios. For example, it can be triggered when a switchover occurs on the master node. During full data synchronization, read replicas are unavailable. If your requests are forwarded to the read replicas, the following error message is returned:
-LOADING Redis is loading the dataset in memory\r\n
.For more information about routing methods, see Features of proxy nodes.
Purchase method
If you have created a cloud-native standard instance, you can enable the read/write splitting feature for the instance. For more information, see Enable read/write splitting.