Try
↑ ↓ move↵ openesc close

Interview prep / Replication and lag

Senior · Replication and lag · System design interview question

You are designing storage for two things: a payments ledger and a social feed. How would you choose replication settings for each?

Sketch your own answer first, then compare it with the one below.

A strong answer

The deciding question is what loss and staleness cost. For the ledger, losing an acknowledged write is unacceptable and a few extra milliseconds per write are fine. Use at least semi-synchronous replication so that every acknowledged write is on two machines, ideally in different failure domains. Accept lower write availability if no follower is reachable. Route reads that must be correct, such as a balance before a debit, to the leader.

For the feed, a stale read is a small blemish and write latency matters more. Asynchronous replication with several followers serving reads is reasonable, with read-your-writes routing so a user sees their own post.

Some details make the design real. Semi-synchronous is usually set up with one acknowledging follower and another ready to take over if it stalls, so a single slow machine cannot block writes. Lag should be monitored and alerted on. A cross-region follower has a long round trip, which makes synchronous replication to it expensive. In each case, be explicit about what is being given up.

Sources

Learn it by running it

The replication and lag lesson explains the mechanism behind this question, and its lab lets you change the parameters and watch the effect.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms