CMD Guide
HomeSystem DesignReplication

Replication Methods

Replication keeps multiple copies of the same data on different nodes, and the single decision that distinguishes every method below is where a write is allowed to land and how that write then propagates to the other copies — that one choice fixes the system's consistency, write-availability, and latency together.

Read the seven methods as points on two axes: how many nodes accept writes (one, several, or any) and how the copy is made (streamed per-change vs. a bulk snapshot). Failover behaviour, conflict handling, and read scaling all fall out of those two choices.

diagram
diagram

1. Single-leader (primary-backup)

Mechanism: one node is the sole writer; it appends every committed change to an ordered log and followers replay that log to converge on the same state. Because all writes pass through one node, they are totally ordered for free and no write conflict is ever possible.

Real system — MySQL: the primary records each committed change in its binlog; replicas open a replication connection, pull binlog events, and replay them (statement- or row-based). PostgreSQL does the same by streaming WAL records (see method 5).

Pros

Cons

2. Multi-leader replication

Mechanism: several nodes each accept writes and asynchronously ship their changes to the other leaders, which merge them; because two leaders can edit the same key concurrently, the system must detect and resolve conflicts (last-write-wins, a version-vector merge, a CRDT, or an application callback).

Real system — CouchDB bidirectional sync: each node accepts updates and exchanges changesets over HTTP; conflicting revisions are kept and flagged for deterministic or callback-based resolution.

Pros

Cons

3. Leaderless (quorum-based) replication

Mechanism: no node is privileged — a client (or coordinator) sends each write to all N replicas and treats it as done once W of them acknowledge; a read queries R replicas and takes the newest version it sees. Configure R + W > N and the read set and the write set are guaranteed to share at least one replica, so at least one responding node always holds the latest write.

Real system — Apache Cassandra / Riak (and the original Amazon Dynamo): tunable per query, e.g. N=3 with W=QUORUM and R=QUORUM. Divergences are healed by read repair and anti-entropy in the background.

Pros

Cons

Worked trace — why R + W > N works (N=3, W=2, R=2)

Three replicas A, B, C all start holding x = 5 (version 1). Watch a write race a read:

StepActionABCClient result
0initial statex=5 (v1)x=5 (v1)x=5 (v1)
1write x=6, need W=2 acksx=6 (v2) ✓x=6 (v2) ✓slow — still x=5 (v1)write OK (2 of 3 acked)
2read, need R=2 → queries B and Creturns x=6 (v2)returns x=5 (v1)returns x=6 (max version)
3read repairx=6 (v2)replicas converged

The write set was {A, B} and the read set was {B, C}. Since 2 + 2 > 3, those sets must overlap — here at B, which carries v2 — so the read is guaranteed to observe the newest write and the client picks the highest version. Drop to W=1 (so R + W = 3 = N) and the sets can miss each other entirely: a write to {A} then a read of {B, C} would return the stale x = 5. That inequality, not any magic, is the whole guarantee.

4. Chain replication

Mechanism: replicas are arranged in a fixed line; every write enters at the head and is forwarded node-by-node down to the tail, and only the tail serves reads and acknowledges the client. A read at the tail therefore reflects every write the tail has already forwarded — you get strong consistency while spreading the update work along the chain.

Provenance — this is not a Google design. Chain replication was introduced by Robbert van Renesse and Fred B. Schneider at Cornell in the OSDI 2004 paper “Chain Replication for Supporting High Throughput and Availability.” It later influenced systems such as Microsoft's CORFU and various object stores, but the invention — and the write-flows-head-to-tail, reads-and-acks-at-tail protocol — is theirs.

Pros

Cons

5. Read-replica replication

Mechanism: a single-leader setup tuned for read fan-out — the leader owns all writes and a fleet of replicas continuously replay its change stream but never accept writes, existing purely to absorb read traffic.

Real system — PostgreSQL streaming replication: the primary writes changes to its Write-Ahead Log (WAL); standbys connect over the streaming protocol, replay WAL records in near-real time, and expose the data as read-only hot standbys that can also be promoted on failover.

The distinction from plain single-leader is intent: single-leader replicas exist mainly for failover/backup and may serve reads; read-replicas are provisioned in bulk (dozens or hundreds) specifically to scale reads and can be placed near users for latency.

Pros

Cons

6. Snapshot replication

Mechanism: instead of shipping every change, the source periodically captures a full, point-in-time copy of the dataset and pushes that entire snapshot to subscribers, which replace their local data with it.

Real system — SQL Server snapshot replication: at publication time the server bulk-generates a snapshot of the tables and schema, delivers it (often via file share), subscribers apply it wholesale, and the cycle repeats on a schedule (e.g. nightly).

Pros

Cons

7. Hybrid replication

Mechanism: compose the above per layer of the topology — e.g. multi-leader between two data centres for cross-region write locality, and read-replica replication within each data centre to scale local reads.

Pitfalls

When to use which (and when not)

Takeaways


Sources: van Renesse & Schneider, “Chain Replication for Supporting High Throughput and Availability,” OSDI 2004 (Cornell); Martin Kleppmann, “Designing Data-Intensive Applications,” ch. 5, for single-/multi-leader, leaderless quorums, and the R + W > N overlap argument; DeCandia et al., “Dynamo: Amazon's Highly Available Key-value Store,” SOSP 2007; MySQL binlog and PostgreSQL WAL streaming-replication documentation; Microsoft SQL Server snapshot-replication documentation. Re-authored / deepened for this guide.

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

Stuck on Replication Methods? 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 **Replication Methods** (System Design) and want to truly understand it. Explain Replication Methods 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 **Replication Methods** 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 **Replication Methods** 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 **Replication Methods** 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