Skip to main content
InterviewHubPRO
Section Overview
Q24

Question 24 of 50

Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

48%
MySQL & InnoDB (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

How does MySQL Replication work (Async, Semi-Sync, Group Replication)?

senior LevelCode ExampleAsync & PromisesDatabases & SQLMySQL

In Simple Words:

  • Asynchronous Replication (Default): Primary commits transactions locally, writes to the Binary Log (binlog), and returns success to client. An I/O thread on the Replica pulls binlog events into a Relay Log, and a SQL thread executes them. Risk: If primary dies before binlog ships, data is lost.
  • Semi-Synchronous Replication: Primary waits until at least one replica acknowledges that the binlog event has been written to its relay log before returning success to the client. Zero data loss on single-node failure.
  • Group Replication (MySQL InnoDB Cluster): Multi-master or single-master cluster based on the Paxos consensus protocol with automatic failover and distributed conflict detection.
text
Replication Data Flow:
[Primary Server]
 └─ Write -> Commit -> [Binary Log]
                             │
                     (Binlog Dump Thread)
                             │ Network
                             ▼
[Replica Server]
 ├─ (I/O Thread) ──► Writes to [Relay Log]
 └─ (SQL Thread) ◄── Reads & Executes SQL locally