Introduction
Configuration
High Availability
MySQL is the world’s most popular open-source database and the second-most-popular database overall. It is used by many of the most accessed applications, such as Facebook, Twitter, Netflix, Uber, Airbnb, Shopify, and Booking.com. KubeBlocks adopts the MySQL distribution provided by ApeCloud, which includes data compression and high availability improvements.
ApeCloud MySQL supports four roles, Leader, Follower, Candidate, and Learner. The Leader and a Follower form a high-availability cluster and ensure RPO=0.
| Role | Leader | Follower | Learner | Candidate |
|---|---|---|---|---|
| Capability | RW/HA | RO/HA | RO | - |

A failover is the redirection of traffic and switches the running tasks from a primary instance to a secondary instance.
Replicas provide read-only capabilities. In addition to the Follower that can provide read-only capabilities, you can also expand the read-only capabilities of the cluster by adding Learner roles. It should be noted that when performing read-only operations through Follower or Learner, there may be a data delay with the Leader. This delay may be caused by a log synchronization delay or a log playback delay.
The cluster supports node fault tolerance. Suppose the number of replicas is n, then the number of faulty replicas that can be tolerated is floor (n/2) + 1, n=[1,99], which meets the requirements of the Paxos algorithm protocol. Based on this, it can be obtained that under the specified tolerable number f of ApeCloud MySQL cluster nodes, the number of replicas that need to be created is n=2*f+1, f>=0. For example, if the tolerable number of faulty replicas is 1, then according to the formula, the minimum number of replicas in the cluster is 3, that is, in a Paxos group, the continuous service capability of the cluster with 1 faulty replica is guaranteed. According to the table below, it can be seen that it is more cost-effective to create an odd number of replicas.
| Replicas in Cluster | Node Majority | Nodes Tolerable |
|---|---|---|
| 3 | 2 | 1 |
| 4 | 3 | 1 |
| 5 | 3 | 2 |
| 6 | 4 | 2 |
| 7 | 4 | 3 |
| 8 | 5 | 3 |
| 9 | 5 | 4 |
| 10 | 6 | 4 |