What is the difference between master-slave and master-master replication?
Database replication strategies fundamentally differ in where writes are accepted, which drives everything from consistency guarantees to operational complexity.
**Master-slave replication** (also called primary-replica) designates a single node as the write target. All writes go to the master; changes are replicated asynchronously (or semi-synchronously) to one or more slaves. Slaves serve read traffic, providing horizontal read scaling. Failover requires promoting a slave to master — a non-trivial operation that must ensure the promoted slave has applied all pending replication events to avoid data loss. This topology is simple to reason about: there is exactly one authoritative state at any point in time, so there are no write conflicts.
The downsides are write throughput ceiling (single write node), and if the master fails before replication completes, the acknowledged writes on the master but not yet replicated are lost — this is the **replication lag** window of data loss. Semi-synchronous replication (MySQL's `rpl_semi_sync`) waits for at least one slave to acknowledge before committing, reducing but not eliminating this window.
**Master-master replication** (multi-primary) allows writes to be accepted by multiple nodes simultaneously. Each node replicates its writes to all other masters. This provides write fault tolerance (any master can fail and writes continue) and potentially lower write latency (clients can write to the nearest node). These benefits come with a fundamental challenge: **write conflicts**. If two masters concurrently update the same row, the system must detect and resolve the conflict — either with last-write-wins (risky), application-level conflict resolution, or CRDTs for specific data types.
In practice, true multi-primary systems are difficult to operate correctly. Tools like MySQL Group Replication and Galera Cluster implement synchronous multi-primary with a distributed consensus protocol (Paxos / Totem) to prevent conflicts at commit time, at the cost of cross-node coordination latency on every write. CockroachDB and Vitess extend this to globally distributed deployments.
For most OLTP workloads, master-slave with read replicas and a robust failover tool (Patroni for PostgreSQL, Orchestrator for MySQL) is the right choice. Master-master is warranted for active-active geo-distribution where write latency to a single region is unacceptable.
| Aspect | Master-Slave | Master-Master |
|---|---|---|
| Write nodes | One (master only) | Multiple |
| Read scaling | Yes (slaves) | Yes (any node) |
| Write fault tolerance | No (master is SPOF) | Yes (any master can fail) |
| Conflict risk | None (single write path) | Yes (concurrent writes to same row) |
| Consistency model | Eventual (async) or strong (semi-sync) | Eventual or strong with consensus overhead |
| Failover complexity | Slave promotion required | Automatic (remaining masters continue) |
| Typical use case | OLTP with read-heavy workload | Active-active geo-distributed writes |
Correctly identifies single vs. multiple write nodes, describes read scaling for both, and names conflict resolution as the master-master challenge.
Explains replication lag and data loss window for master-slave, discusses conflict detection/resolution strategies for master-master, names specific implementations (Galera, Group Replication, Patroni), and articulates when each topology is the right choice.
Reading the answer is step one. Explaining it unprompted — under interview pressure — is what actually matters. Get AI-graded feedback on your answer with follow-up probes on your weak points.
Get Graded — Free Assessment