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
- Martin Kleppmann (2017). Designing Data-Intensive Applications.
- Douglas Terry, Alan Demers, Karin Petersen, Mike Spreitzer, Marvin Theimer, Brent Welch (1994). Session Guarantees for Weakly Consistent Replicated Data.