CMD Guide
HomeSystem DesignDatabases

Data Replication vs Data Mirroring

Both replication and mirroring keep a second copy of your data on another machine. The confusion comes from treating them as synonyms. They differ on three axes that actually matter in a design: how many copies exist, how tightly the copies are kept in sync, and what problem the copy is there to solve. Get those three right and the rest follows.

A useful one-liner: replication is a family of copy strategies optimised for scale and locality; mirroring is one strict member of that family optimised for failover. Most real systems use both — mirror (or synchronous replica) for the failover pair, plus asynchronous replicas fanned out for read scaling and reporting.

diagram
diagram

Data replication

Replication copies committed changes from a source to one or more targets. The single most important knob is the acknowledgement point:

Two acronyms anchor everything on this page. RPO (Recovery Point Objective) is how much acknowledged data you can afford to lose, measured backwards from the failure — synchronous replication makes it ~0 because nothing is acked until a second copy has it; asynchronous leaves an RPO equal to the replication lag at the moment of failure. Its inseparable twin RTO (Recovery Time Objective) is how long until service is restored — automatic failover (witness present) shrinks RTO to seconds, while manual failover makes RTO a paging-and-runbook number. The pair gets a full treatment in What Are RPO and RTO, and How Do They Differ in Disaster Recovery Planning.

Because replicas are independent copies, replication is the tool for scaling reads (fan reads out across replicas), data locality (put a copy near each region's users), and offloading analytics/reporting away from the transactional primary. Topologies range from single-leader (one writable primary, many read replicas) to multi-leader and leaderless designs. Example: a service runs a synchronous replica in the same region for durable failover and three asynchronous replicas across regions to serve low-latency local reads.

Data mirroring

Mirroring maintains one exact standby copy for failover. In SQL Server's database-mirroring feature the roles are named precisely and worth learning, because the terminology recurs across HA systems:

Mirroring runs in one of two operating modes:

Example: a payments system mirrors its transaction database synchronously with a witness so that if the principal server dies, the mirror is promoted automatically with no committed transaction lost.

Mirroring below the database

The word mirroring also names a storage-layer arrangement — RAID-1, synchronous SAN replication, DRBD — which duplicates disk blocks, not transactions. Block mirroring is engine-agnostic and mirrors everything, including torn pages and filesystem corruption, and it cannot distinguish committed from uncommitted bytes; database-level mirroring/replication ships log records, so the standby applies only well-formed transactions. Rule of thumb: block mirroring protects the volume, log shipping protects the database — which is why a SAN-mirrored volume can faithfully reproduce a corrupted data file while a log-shipping standby stays clean.

diagram
diagram

Failover, with numbers

Put the two operating modes side by side on one concrete workload: a principal accepting 1,000 tx/s, with the mirror running 50 ms behind when the link is asynchronous.

TimelineHigh-performance mode (async)High-safety mode + witness (sync)
Steady stateCommits ack immediately; the mirror trails by ~50 ms of log.Every commit waits until the mirror has hardened the log record — commit latency grows by ≈ one partner round trip on every write.
t0 — principal diesThe un-shipped tail is gone: RPO = lag × write rate = 0.05 s × 1,000 tx/s = 50 acknowledged transactions lost.The mirror already holds every acknowledged commit: RPO = 0.
FailoverForced service, manual: someone is paged, confirms the principal is really dead, forces the mirror into service — RTO = minutes (a paging-and-runbook number).Witness + mirror vote the principal dead on heartbeat timeout and promote automatically — RTO ≈ heartbeat timeout + role switch = seconds.

The two modes are the two ends of the RPO-vs-write-latency dial: high-performance buys back the per-commit round trip and pays 50 transactions at failure; high-safety pays the round trip on every write and loses nothing.

Key differences at a glance

DimensionReplicationMirroring
Number of copiesOne to many; copies are independentExactly one mirror per primary (1:1)
Sync modelSynchronous or asynchronous (your choice)High-safety (sync) or high-performance (async), but always a strict standby pair
Primary purposeRead scaling, locality, reporting, availabilityHigh availability and disaster recovery (failover)
Do copies serve traffic?Yes — replicas commonly serve readsNo — classic mirror is a hot standby, not readable
Write-path impactTunable; async keeps writes fastSync mode adds commit latency (waits for mirror)
Automatic failoverDepends on the system/orchestrationOnly in high-safety mode with a witness

Note the overlap: a synchronous single replica used purely as a standby is effectively mirroring. The labels describe intent and configuration more than fundamentally different machinery.

Pitfalls and gotchas

Source

Witness, quorum, operating-mode (high-safety vs high-performance), and "runs exposed" behaviour follow Microsoft's SQL Server documentation on database mirroring: "Database Mirroring (SQL Server)", "Role Switching During a Database Mirroring Session", and "Quorum: How a Witness Affects Database Availability" (learn.microsoft.com / SQL Server product documentation). General replication concepts (synchronous vs asynchronous, single-leader read scaling, RPO trade-offs) follow standard distributed-systems treatments such as Kleppmann, Designing Data-Intensive Applications, Ch. 5 ("Replication").

Interview drill ladder

🎯 Drill Ladder — survive the follow-ups

L0 · replication is a family of copy strategies for scale and locality; mirroring is the strict 1:1 failover member of that family — the axes that matter are copy count, sync tightness, and purpose.

L1 · “What is RPO, and how does synchronous replication make it ~0?”
Trap: “RPO is how long recovery takes.” (that’s RTO — conflating the twins is the classic miss)
Bar: RPO (Recovery Point Objective) is how much acknowledged data you can afford to lose, measured backwards from the failure. Synchronous replication makes it ~0 because the ack is withheld until the mirror has hardened the log record — so the committed set on the pair is identical at all times; asynchronous leaves an RPO equal to the replication lag (50 ms of lag at 1,000 tx/s = 50 transactions, per the failover table above).

L2 · “When does a witness help vs hurt availability?”
Trap: “a witness always improves availability — it’s an extra vote.”
Bar: A witness adds an availability failure mode: on quorum loss (principal isolated from both partners) the database goes offline to prevent split-brain, whereas witness-less high-safety runs exposed instead — degraded but serving. So a witness helps when you need automatic failover and can place it in a third failure domain; it hurts when it shares a failure domain with a partner — its loss plus one link flap can fence a perfectly healthy principal.

L3 · “Why is replication not a backup?”
Trap: “we have three copies, so we’re backed up.”
Bar: Replication copies bad writes at replication speed — the accidental DELETE reaches every copy within the lag window, and the mirror applies it as faithfully as any legitimate transaction. Copies protect against hardware and site failure; only point-in-time backups give you a pre-mistake state to restore.

🤖 Don't fully get this? Learn it with Claude

Stuck on Data Replication vs Data Mirroring? Open Claude, copy a block below, and it'll teach you this exact concept — visually and interactively.

🎨 Explain it visually

Build the mental picture, not memorization.

I just read a lesson on **Data Replication vs Data Mirroring** (System Design) and want to truly understand it. Explain Data Replication vs Data Mirroring from first principles using ONE vivid real-world analogy and a visual mental model — draw it as ASCII art or a clear step-by-step diagram — with a concrete example using real numbers. Then ask me one question to check I got the mental picture, and wait for my reply. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🤔 Walk me through it (interactive)

Socratic — adapts to where you're stuck.

Teach me **Data Replication vs Data Mirroring** interactively. Ask me ONE guiding question at a time, wait for my answer, and adapt to my confusion — build the idea with me step by step instead of explaining it all at once. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🧪 Quiz me & fix my gaps

Active recall exposes what you missed.

Quiz me on **Data Replication vs Data Mirroring** with 5 questions, easy to tricky, ONE at a time. Tell me if each answer is right; at the end, explain clearly what I got wrong and why. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🧠 Make it stick

Intuition + hook + flashcards for long-term memory.

Help me remember **Data Replication vs Data Mirroring** for the long term: give the one-sentence intuition, a memorable hook/mnemonic, a tiny worked example, and 3 active-recall flashcards (Q -> A). If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.

📝 My notes