×
Community Blog RDS for MySQL: Read-only Instance Learner and X-Paxos Consensus Protocol Integration

RDS for MySQL: Read-only Instance Learner and X-Paxos Consensus Protocol Integration

A tutorial of the Three-node Enterprise Edition of RDS: using a read-only instance to process read requests and integrating X-Paxos consensus protocol.

Read-only Instance Learner in the 3-node Enterprise Edition of RDS for MySQL

By using the learner role from X-Paxos, the Three-node Enterprise Edition allows creating read-only instances to elastically scale the read capability and share the load of the primary database. Use read-only instances to process massive volumes of read requests sent to the database to increase the throughput of applications. Currently, the Alibaba Cloud official website allows users to create and use read-only instances in the Three-node Enterprise Edition of RDS 5.7. We welcome you to try it out.

Background

Read/write splitting is a common method of using databases. Middleware, like a MySQL proxy, transfers the traffic to a primary node to write and edit, and forwards query traffic to a read-only mode. This frees up the primary node's CPU and I/O power and increases the overall availability of the database.

Features of the Learner

The Three-node Enterprise Edition implements read-only instances by adding a learner. The learner receives committed logs from the leader and stores the logs in the consensus log. The secondary thread reads and distributes the logs to worker threads. Finally, the logs are concurrently played back to the state machine. In this case, the learner node is read-only for external clients.

Users who have used MySQL cloud products may be familiar with the concept of read-only nodes. In the Dual-node High-availability Edition, two instances are initially generated. One is a primary node that performs read and write operations. The other is a secondary node in a read-only state. However, this node is not exposed to users and does not provide the read service externally. To add a read-only instance to support read/write splitting, the console creates a secondary node through backup and mounts it to the primary node. When this node synchronizes the latest data from the primary node, that is, when Second_Behind_Master is 0, it begins to provide the read service externally. The following figure shows the deployment mode of the nodes.
deployment mode of the nodes
The read-only nodes of the Three-node Enterprise Edition are similar to those used in MySQL cloud products. First, a new learner node is created through backup and mounted to the leader. Then, the learner begins to receive and playback incremental consensus logs. When the logs played back to the learner node and catch up with the logs on the leader node, the learner node enables the external read service. The following figure shows the deployment mode of the nodes.

the deployment mode of the nodes

Compared to the read-only nodes of the High-availability Edition, the learner has the advantage of being connected to the X-Paxos system. This ensures that the data on the learner is consistent with that in the three-node cluster, regardless of failover between the primary node (the leader) and the disaster recovery nodes (the follower and the secondary node).

Assuming that in a dual-node high-availability scenario, the primary database updates the value of x from 1 to 2 and synchronizes the change only to the read-only node, but not to the secondary database. If the primary database fails, the secondary database becomes the new primary database, and the read-only node points to this secondary database. In this case, the data in the new primary database is inconsistent with that on the read-only node, because the value of x is 1 in the new primary database and 2 in the read-only node. If the service or database administrator (DBA) detects the database inconsistency and performs data backfilling to update the value of x in the new secondary database from 1 to 2 when the binary log of the transaction is synchronized to the read-only node, the SQL thread on the read-only node returns an error and exits. This exception is handled only through manual intervention. If a large amount of data needs to be backfilled, it is impossible to complete this operation through manual O&M. You must re-create a read-only node based on the backup of the new primary database. This makes the read-only node unavailable for a period of time. However, this problem does not occur in the Three-node Enterprise Edition.

This article evaluates how to use a read-only instance in the Three-node Enterprise Edition of RDS for MySQL to process massive volumes of read requests.

How Does the RDS 5.7 3-node Enterprise Edition Integrate X-Paxos Consensus Protocol Based on AliSQL?

With the development of the Internet, customers in the cloud are stressing more and more on data security, and many industries require data storage across data centers and regions. The RDS 5.7 Three-node Enterprise Edition is a cloud-based database solution built on proprietary Alibaba technologies. It is designed for users with high data quality requirements.

Background

The RDS 5.7 3-node Enterprise Edition is a high-availability and strongly consistent database product incubated at Alibaba Group with support for global deployment. This product has been used in Alibaba Group's own businesses since 2017, providing reliable support for the Double 11 Shopping Festival over many years. After two years of internal polishing, this edition was officially made available on the public cloud in July 2019. Compared to the RDS 5.6 three-node edition, we adopted a new kernel design, especially in terms of the consensus protocol.

The core of the Three-node Enterprise Edition is the consensus protocol. In version 5.7, we integrated the consensus protocol library X-Paxos developed by Alibaba into AliSQL. In addition to 100% compatibility with MySQL, we implemented automatic primary database selection, log synchronization, strong data consistency, and online configuration changes. X-Paxos adopts the Multi-Paxos implementation solution for unique proposers and provides many innovative features and performance optimizations. X-Paxos is a consensus protocol that has greater significance in the production environment.

This article explores how the RDS 5.7 Three-node Enterprise Edition designed for users with high data quality requirements incorporates the X-Paxos Consensus Protocol based on AliSQL.

Related Products

ApsaraDB RDS for MySQL

MySQL is one of the most popular open-source databases in the world. As a key component of the open-source software bundle LAMP (Linux, Apache, MySQL, and Perl/PHP/Python), MySQL has been widely applied to different scenarios.

Related Documentation

Overview of AliSQL features

This topic provides an overview of the features that are provided by AliSQL. This topic also provides a comparison between AliSQL and other MySQL versions.

Overview of ApsaraDB RDS for MySQL

This topic provides an overview of ApsaraDB RDS for MySQL and describes the related terms.

0 0 0
Share on

Alibaba Clouder

2,605 posts | 747 followers

You may also like

Comments