Replication in System Design Interviews: When to Use It and What to Say
Replication is the practice of storing copies of the same data on more than one server. In an interview you bring it up when the system must stay up despite node crashes or when users in different regions need fast reads.
Why Replication Matters
Imagine a URL-shortener service that receives 10 million requests per day. That is roughly 115 requests per second. If a single database node goes down, every request fails. By replicating the data across three nodes, the service can tolerate the loss of any one node and still serve the full traffic. The problem solved is two-fold: availability (the system keeps working) and read latency (users can be served from a nearby replica).
How Replication Works – Step by Step
- Write Path – The client sends a write request to the front-end (e.g., an API gateway). The request is routed to the leader (or primary) node.
- Log Append – The leader appends the change to its write-ahead log. This log is the source of truth for ordering.
- Propagation – The leader streams the log entry to follower nodes. In a quorum system, the write is considered committed once a majority of nodes acknowledge.
- Ack to Client – After the required acknowledgments, the leader replies to the client. The client sees a successful write even though the data is still being copied.
- Read Path – Subsequent reads can be served from any replica that has applied the log entry. For low-latency reads, the client may be directed to the nearest replica.
Small Worked Example
Suppose we have a three-node cluster: Node A (leader), Node B, and Node C. The client wants to set url = "abc" → "https://example.com".
| Step | Action | Result |
|---|---|---|
| 1 | Client → API → Node A | Write request arrives at leader. |
| 2 | Node A writes to its log | Log entry seq=101 created. |
| 3 | Node A streams seq=101 to B & C | B and C receive the entry. |
| 4 | B and C ACK | Leader sees two acknowledgments (majority of 3). |
| 5 | Node A replies success | Client gets 200 OK. |
| 6 | B and C apply entry | Data now present on all three nodes. |
| 7 | Subsequent reads → B (closest) | Read latency reduced. |
If Node B crashes after step 3, Node C still holds the data, and the system continues serving reads. When Node B recovers, it catches up by replaying the log from the leader.
Classic Interview Questions Where Replication Shows Up
| Question | Where Replication Appears |
|---|---|
| Design a Social Media Feed | Replicating user-timeline data across data centers to serve low-latency reads and survive a region outage. |
| Design a URL Shortener | Using leader-follower replication for the mapping table, ensuring the service stays up if the primary DB fails. |
| Design a Global Chat Service | Multi-master replication (or CRDT-based) so that messages appear in all regions without a single leader bottleneck. |
In each case the interviewer will probe the placement of the leader, the consistency model (strong vs eventual), and the failure handling strategy.
Trade-offs and the Alternative Interviewer May Ask
| Aspect | Replication Benefit | Cost / Trade-off |
|---|---|---|
| Availability | System survives node/zone loss. | Requires extra hardware and network bandwidth. |
| Read Latency | Reads can hit a nearby replica. | Writes become slower due to coordination. |
| Consistency | Strong consistency via quorum gives correct reads. | Higher write latency; may need to sacrifice immediacy for speed (eventual consistency). |
| Complexity | Failover logic is encapsulated in the replication protocol. | Operational complexity: monitoring lag, handling split-brain, re-sync after recovery. |
The alternative the interviewer often explores is sharding. Instead of copying the same data, you partition it across nodes. Sharding scales write throughput but does not protect against a node failure for the data it owns. Candidates should be ready to compare replication vs sharding and explain why one fits the SLA better.
A 30-Second Pitch You Can Say Out Loud
"Replication copies data across multiple machines to avoid a single point of failure and to serve reads from the nearest copy. In a typical leader-follower setup, the leader writes to a log, streams it to followers, and waits for a majority to ack before confirming to the client. This gives us high availability and lower read latency, but it adds write latency and operational complexity. In interviews you’ll see it in designs like a global feed, a URL shortener, or a chat service, where the trade-off between consistency and latency becomes the key discussion point."
Common Mistakes Candidates Make
- Claiming "instant" consistency without explaining the protocol. Interviewers expect you to mention quorum, write-ahead logs, or eventual sync.
- Ignoring replica lag. Saying reads are always up-to-date overlooks the window where a follower may be behind the leader.
- Over-estimating durability. Assuming a single replica is enough; durability requires at least two acknowledgments in most designs.
- Skipping failure scenarios. Not describing what happens if the leader crashes, how a new leader is elected, or how data is recovered.
- Mixing up sharding and replication. Treating them as interchangeable shows a lack of understanding of their distinct goals.
How to Practice This
- Study the worked design of a wide-column store like Cassandra in the System Design AI library. Observe how the diagram builds up one request path at a time, and note that Cassandra replicates without a single leader, so compare it with the leader-follower flow above.
- Create your own canvas for a classic question (e.g., a URL shortener). Sketch the replication components, label the log, and write a short note on the consistency level you choose.
- Run a mock interview where you explain the replication choice, walk through a write request, and answer follow-up questions about failure handling and trade-offs.
Questions people ask
When should I choose replication over sharding?
Replication is best when you need high availability and low read latency for the same dataset. Sharding is preferred when write throughput is the bottleneck and the data can be partitioned safely.
What is the difference between leader-follower and multi-master replication?
Leader-follower has a single writer that orders updates; multi-master allows writes on any node but requires conflict-resolution mechanisms such as CRDTs or consensus protocols.
How do you handle a split-brain scenario?
Most systems use a consensus algorithm (e.g., Raft) that forces a majority to agree on the leader. If a minority partition thinks it is the leader, its writes are rejected once the majority rejoins.
Can replication guarantee zero data loss?
Zero loss is only possible if the write is persisted on a majority of nodes before acknowledging the client. If fewer nodes store the data, a simultaneous failure could lose the write.