Replication
maang.io System Design Series
Replication keeps copies of your data on multiple machines so the system survives failures and serves reads at scale. The whole subject is choosing who can accept a write and how fast copies converge — single-leader (simple, one writer), multi-leader (write anywhere, resolve conflicts), or leaderless quorums (Dynamo-style). Every choice trades consistency against availability, the CAP tension made concrete.
This deep dive comes in three parts:
- Foundations & Core Concepts — the three replication models and synchronous vs asynchronous.
- Internals — replication logs, lag, read-after-write guarantees, and failover/split-brain, with worked numbers.
- Interview — Staff/Principal Q&A: consistency guarantees, failover reasoning, and model selection.
Replication — Part 2: Internals & Implementation
maang.io System Design Series
What is this?
Back to the bank. In Part 1 we said the leader "streams its changes down to the followers." That sentence hides three deep questions a Staff engineer has to answer precisely:
- What exactly gets shipped? Do you send "post a $50 deposit to account 42" (an instruction to re-run), or the literal changed bytes of the ledger page? This is the replication log format — and getting it wrong silently corrupts your copies.
- What can a reader observe while a follower is behind? Replication lag isn't just "slow" — it lets clients see impossible things (their own deposit vanishing) unless you pick the right consistency guarantee.
- What happens the instant head office burns down? Promoting a branch — failover — is the most dangerous ten seconds in the life of a database, and if you botch it, two branches both start posting entries and your ledgers diverge forever (split-brain).
Let's take them in order, then do a worked quorum example with real numbers, then name the failure modes that get real teams paged.
Sign in to continue reading
The rest of this lesson is available with a free account. Signing in with Google or Microsoft is free.
Sign in to read the full lesson