System Design (High-Level Design) Module 8
Replication interview questions
Interview questions on replication: short warm-ups, then what each harder question tests, the first step of a good answer and its follow-ups.
Warm-up questions
Short questions with short answers, each answered in full.
-
Fresher to mid
What is the difference between synchronous and asynchronous replication?
Answered in the lesson Leader-follower replication and replication logs
-
Fresher to mid
Why can statement-based replication leave a replica with different data?
Answered in the lesson Leader-follower replication and replication logs
-
Fresher to mid
What are read-your-writes, monotonic reads and consistent prefix reads?
Answered in the lesson Replication lag and read-your-writes guarantees
Questions with model answers
What each question tests, the first step of a good answer and the follow-ups to expect.
-
Mid to senior
Your orders database replicates asynchronously to two followers. At peak it takes 3,000 writes a second and replication lag reaches 400 ms. The leader's disk fails at peak. How many acknowledged orders can you lose, and how would you bound that number?
- What it tests
- The loss window of asynchronous replication, estimating it from write rate and lag, and choosing commit modes, alerts and recovery steps that bound it.
- First step
- Lost writes are the acknowledged writes the promoted follower had not received, so the loss is about the write rate times that follower's lag at the moment of failure: 3,000 × 0.4 s, or up to 1,200 orders at peak lag. Then ask how many lost orders the business can accept.
- Follow-ups
-
- The business says no acknowledged order may ever be lost. What changes?
- After the failover, how do you work out which orders were lost?
- Would MySQL's semi-synchronous replication solve the problem?
From the lesson Leader-follower replication and replication logs
Model answer, Pro. Model answers open with any pass; prices are in the notice on this page.Opening the model answers with your pass…
Model answers open with any MySmartCoPilot pass.
- Pro pass · 1 week₹79$2.99
- 30 days₹179$5.99
- 1 year₹1,699$45
One payment; a pass never renews. The price shown is the total you pay: no fees or charges are added at checkout.
Passes can’t be bought right now, so the model answers can’t be opened at the moment. If you have a pass, enter your licence key.
It also opens every other in-depth part in Learn and every Pro tool. Sales are final, except where the law gives you a right to withdraw, for example in the EU and the UK (refund policy).
In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 4 minutes
-
Senior to staff
A team wants every commit to an orders database in Mumbai to wait for a synchronous standby in Singapore, about 3,900 km away, so that losing a whole region loses no order. What does that cost, and what would you propose instead?
- What it tests
- Latency floors of synchronous replication across regions, the availability cost when the remote standby is unreachable, and how to separate zone failures from region disasters.
- First step
- Start from physics: 3,900 km of fibre is at least 39 ms of round trip, so every commit waits at least that long, and a request with several writes in a row pays it each time. Then ask which failure the team fears: a lost server or zone, which is common, or a lost region, which is rare.
- Follow-ups
-
- What happens to commits when the link to Singapore fails?
- How would you protect against losing a zone, as opposed to a region?
- What recovery point can you honestly promise with your design?
From the lesson Leader-follower replication and replication logs
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
Your failover controller declares the primary dead after 3 missed heartbeats sent every second. Twice this month a 4-second garbage-collection pause on a healthy primary triggered a failover, and a few acknowledged writes were lost each time. How do you choose the timeout, and what else would you change?
- What it tests
- Failure-detector trade-offs between outage length and false failovers, and why a false failover costs data when replication is asynchronous.
- First step
- Write down both costs. A real crash costs roughly the timeout as a write outage; a false failover costs the asynchronous loss window and risks two leaders. A 4 s pause beats a 3 s timeout, so either the timeout must exceed the longest pause a healthy primary makes, or the pause must go.
- Follow-ups
-
- How would you measure the longest pause a healthy primary makes?
- Would synchronous replication make false failovers harmless?
- How does giving the primary a lease change the picture?
From the lesson Failover, split brain and fencing
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Senior to staff
After a network partition heals, you find that the old primary and the promoted standby both accepted writes for 30 seconds. What do you do with the old primary's writes now, and how do you make sure it cannot happen again?
- What it tests
- Handling divergent histories after split brain, bringing the old primary back safely, reconciliation, and fencing designs that prevent two writable leaders.
- First step
- Stop writes on the old primary at once, save a copy of everything only it accepted, and make the promoted standby the single source of truth before deciding anything else. Every later step is easier when the damage stops growing.
- Follow-ups
-
- Which of the saved writes can be reapplied automatically, and which cannot?
- Which fencing method fits a database running on virtual machines?
- How would you detect split brain while it is happening?
From the lesson Failover, split brain and fencing
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Senior to staff
A job scheduler takes a 10-second lease from a lock service so that only one worker writes each job's result. Now and then a result is overwritten by an older run of the same job, yet the lock service never handed out two leases at once. How does this happen, and how do you fix it?
- What it tests
- Why leases alone cannot provide mutual exclusion when processes pause or clocks misbehave, and where the check that prevents stale writes must happen.
- First step
- Look for the gap between checking the lease and writing the result. A worker that checks, then pauses longer than the time left on its lease, writes after the lease has passed to another worker, and the lock service never sees that write.
- Follow-ups
-
- What if the storage cannot check anything on a write?
- Does a shorter lease help?
- How would you reproduce the bug in a test?
From the lesson Failover, split brain and fencing
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
Users report that after editing their profile, the page shows the old name for a few seconds, and sometimes the new name appears and then disappears on refresh. Reads go to three replicas behind a load balancer. Diagnose it, and fix it without sending every read to the primary.
- What it tests
- Recognising read-your-writes and monotonic-read violations from user symptoms, and choosing a routing fix with its costs.
- First step
- Name the two anomalies: the old name right after saving breaks read-your-writes, and new then old on refresh breaks monotonic reads. Both come from one user's reads landing on replicas at different log positions. Measure replica lag before choosing a fix.
- Follow-ups
-
- Why not send a user's reads to the primary for five seconds after each write?
- The user edits on a phone and checks on a laptop. Does your fix still work?
- How would you test the fix before shipping it?
From the lesson Replication lag and read-your-writes guarantees
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Senior to staff
Your team sends a user's reads to the leader for one second after each write. Complaints about missing edits fall, but complaints that content jumps back to an older state rise. Explain why, and design a better routing rule.
- What it tests
- How a time window interacts with replica lag, and designing position-token routing with its operational details.
- First step
- Follow one session across the end of the window. Reads inside it come from the leader, which is always ahead; the first read after it can land on a lagging follower that is behind what the user has already seen. The window turns one anomaly into another.
- Follow-ups
-
- Where does the token live, and who updates it?
- What happens to tokens when the leader fails over?
- How do you bound the extra latency when no follower has caught up?
From the lesson Replication lag and read-your-writes guarantees
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Senior to staff
Your system uses log-position tokens for read-your-writes. After a failover, a few users find that writes they made a minute earlier are gone, although every follower they read from had passed their token. What happened, and how do you change the design?
- What it tests
- How log positions behave across a change of leader, and how to validate tokens so that a passed position really means the write is present.
- First step
- Start from what a token means: a position in one leader's log. Work out what the positions on the new leader refer to, compared with the old leader's, for writes the old leader acknowledged just before it failed.
- Follow-ups
-
- How does PostgreSQL mark the new history after a standby is promoted?
- Should tokens issued before the failover be rejected or translated?
- What do you tell the users whose writes were lost?
From the lesson Replication lag and read-your-writes guarantees
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
Your app has writable databases in two regions. A user changes their delivery address on a phone served by one region while a support agent changes it in the other, and last-writer-wins resolves the conflict. What can go wrong, and what would you change?
- What it tests
- Recognising silent data loss from last-writer-wins, the effect of clock skew, and avoiding conflicts by giving data a home region.
- First step
- Spell out what last-writer-wins does here: one of the two addresses is discarded and nobody is told, and if the regions' clocks disagree the older edit may be the one that survives. Then ask whether this data needs two writable regions at all.
- Follow-ups
-
- How would you even detect that a conflict happened?
- What if the two edits changed different fields of the address?
- When would last-writer-wins be acceptable for this data?
From the lesson Multi-leader replication and conflict resolution
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Senior to staff
Design sync for a notes app that works offline on a phone and a laptop. Both devices edit the same note while offline. How do you detect the conflict, what do you keep, and how do you stop deleted notes from coming back?
- What it tests
- Version vectors per device, handling concurrent versions, merging text and lists, and deletion markers with their clean-up.
- First step
- Give each device its own counter in a version vector stored with every note. On sync, compare the vectors: if one is ahead in every entry, take it; if each is ahead somewhere, the edits were concurrent and must be merged or both kept. A deletion has to be recorded, not inferred from absence.
- Follow-ups
-
- How do you merge two edits of the same paragraph?
- When can the deletion records be removed?
- How large do the version vectors grow, and what do you do about it?
From the lesson Multi-leader replication and conflict resolution
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
A video platform counts likes in three regions, each with its own writable database. Design the like counter so that all regions agree in the end, users can remove a like, and repeated replication messages never inflate the count.
- What it tests
- Designing a counter that converges without coordination, merges that tolerate repeats and reordering, per-user semantics, and the limits of such data types.
- First step
- Start from the failure the prompt names: replication messages repeat and arrive in any order, so the merge must give the same result however often and in whatever order it runs. Then decide what each region owns, so that no two regions ever change the same number.
- Follow-ups
-
- How do you stop one user liking the same video twice?
- How many bytes does the counter take, and does it grow over time?
- Could the same design count the stock left in a flash sale?
From the lesson Multi-leader replication and conflict resolution
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
A shopping-cart service keeps each cart on N = 3 replicas of a leaderless store. Carts must keep accepting writes when one replica is down, and users must see their own change on the next page. Choose R and W, and say what can still go wrong.
- What it tests
- Choosing quorum sizes from failure tolerance and read-after-write needs, and knowing the gaps that quorums leave.
- First step
- Turn each requirement into an inequality: writes that survive one failure need W of at most 2, and reads that see the user's own write need R + W greater than 3. W = 2 and R = 2 satisfy both, and each operation then tolerates one failure.
- Follow-ups
-
- Two browser tabs add different items to the same cart at the same moment. What happens?
- A replica is down for six hours. What brings it up to date?
- Why not W = 1 and R = 3?
From the lesson Leaderless replication and quorums: N, R and W
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Senior to staff
Your store uses N = 3, R = 2 and W = 2, yet a support ticket shows a customer reading a new value and then an older one a moment later. A colleague says that is impossible because R + W > N. Who is right, and how could it happen?
- What it tests
- Precisely what quorum overlap guarantees and what it does not: reads during writes, failed writes, sloppy quorums and read repair.
- First step
- Separate the guarantee from the claim. Overlap promises that a read after an acknowledged write meets it; it promises nothing about reads that run while a write is still landing, writes that failed but partly landed, or writes accepted outside the key's usual replicas. Ask what was being written at the time.
- Follow-ups
-
- What does blocking read repair change?
- Would R = 3 fix it?
- How would you get linearisable reads for this key?
From the lesson Leaderless replication and quorums: N, R and W
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Senior to staff
During a network partition your leaderless store can either accept writes for a key on substitute nodes, a sloppy quorum, or reject them. Which would you choose for shopping carts, and which for an inventory counter, and what must be in place either way?
- What it tests
- Trading write availability against consistency per data type, the limits of hinted handoff, repair, and conflict handling after the partition.
- First step
- Decide per data type by comparing what a rejected write costs with what a stale or conflicting write costs. A cart can accept writes and merge them later; a stock count that must never go below zero cannot be safely merged after the fact.
- Follow-ups
-
- What happens if a substitute node fails before it hands the write back?
- How long does Cassandra keep hints for a node that is down, by default?
- How do you know that the replicas converged after the partition?
From the lesson Leaderless replication and quorums: N, R and W
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
All System Design (High-Level Design) interview questions · The System Design (High-Level Design) track