Video in progress
Within one product, how do you choose different consistency levels for different features?
For each feature I ask "what goes wrong if stale data is shown?". Strong consistency for money, inventory and unique constraints, read-your-writes for a user's own changes, and eventual is enough for counters and recommendations.
📖 Answer
A requirement like "the whole system must be strongly consistent" makes latency and availability more expensive everywhere. "Everything eventual" leads to accidents with money and inventory. The staff-level job is to draw that line per feature and explain it to the teams.
This is how I group things in practice:
- Linearizable / strong: balance, payment status, booking the last seat, claiming a username. One leader, a transaction, and
SELECT ... FOR UPDATEif needed. The cost is cross-region latency, and writes stop during a partition. - Read-your-writes: profile, settings, my own post. If others see it 2 seconds late, fine, but if I save something and then see the old value, I'll think it's a bug. Put the last write version in the session, and read from the primary if the replica hasn't reached that version.
- Monotonic reads: a list of comments. If a comment appears on refresh and then disappears, that's weird. Pinning the user to one replica is enough.
- Eventual: like count, view count, search index, recommendations. A delay of a few seconds or minutes bothers nobody.
Write these decisions down, next to each API: "consistency: read-your-writes, max staleness 5s". Otherwise one team adds a cache and silently breaks another team's assumption.
This is where people often slip in interviews: the boundary between features. An order is strongly consistent, but if the "my orders" list is read from a search index, the user won't see their order in the list after paying. Finding such boundaries up front is one of the main questions in a design review.
Sign up to mark studied questions and save your progress.