Skip to content
MySQL High Availability Architectures: Master-Slave, MHA, MMM, and MGR Compared
Databases 5 min read

MySQL High Availability Architectures: Master-Slave, MHA, MMM, and MGR Compared

This article explains MySQL high availability architectures including master-slave replication (async and semi-sync), MHA for automated failover, MMM for dual-master VIP switching, and MGR based on Paxos for strong consistency, detailing their principles, trade-offs, and use cases.

Linyb Geek Road
Linyb Geek Road
Linyb Geek Road

1. Master-Slave Replication

Normal operation: only Master handles writes; Master and Slave stay consistent via replication. On Master failure, a Slave is promoted.

Master-slave replication diagram
Master-slave replication diagram

Replication principle:

Master writes changes to binlog.

Slave IO thread connects to Master, reads binlog.

Slave IO thread writes to relay log.

Slave SQL thread executes SQL from relay log to replay data.

MySQL replication is asynchronous; Master commits transaction and returns immediately, risking data loss.

Semi-sync replication diagram
Semi-sync replication diagram

MySQL 5.5 introduced semi-synchronous replication:

Master waits for at least one Slave to acknowledge receipt of binlog (written to relay log, not necessarily executed) before committing.

Replication storm: Master overwhelmed by many Slaves. Solution: Slave-to-Slave replication.

2. MHA (Master High Availability)

Detects node failures and performs master-slave failover.

MHA architecture diagram
MHA architecture diagram

Components:

MHA Manager: decision layer, auto-detects Master failure, checks replication status, executes automatic failover.

MHA Node: deployed on each MySQL server, repairs master-slave data differences.

Failover process:

MHA Manager periodically probes Master heartbeat; 4 consecutive missed heartbeats triggers failover.

Manager compares Slaves' binlog positions; the Slave with binlog closest to Master becomes candidate Master.

MHA Node attempts SSH to Master server: if reachable, sync missing data; if unreachable, Slaves compare relay logs to sync differences.

Manager establishes new master-slave topology, promotes candidate to Master, other Slaves replicate from new Master.

3. MMM (Multi-Master Replication Manager for MySQL)

MMM is a dual-master failover and management script component with two Masters providing high availability.

MMM dual-master diagram
MMM dual-master diagram

MMM switches Master by moving virtual IP. When Master 1 fails, Master 2 takes over immediately, transparent to clients. However, MMM is outdated, does not support MySQL GTID, low community activity, and is unmaintained.

4. MGR (MySQL Group Replication)

MGR group replication diagram
MGR group replication diagram

MGR is based on the Paxos protocol, providing strong consistency across nodes and zero data loss. In a group of 2N+1 nodes, MGR tolerates N node failures, offering high fault tolerance.

Trade-off: strong consistency requires each write to communicate with a majority of nodes, so write performance is lower than asynchronous or semi-synchronous replication. MGR suits scenarios demanding strong consistency with moderate write load.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

High AvailabilityMySQLMMMMHAPaxosMaster-Slave ReplicationMGRSemi-sync Replication
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.