System design fundamentals learning path Level 2 This level · 10 of 20
Medium system-design fundamentals

What consistency models should you know, from linearizable to eventual?

The 30 second answer

Linearizable is the strongest for a single object: every operation looks like it happened at one instant, in real-time order, as if there were one copy. Sequential keeps one order everyone agrees on but not tied to real time, and causal only orders operations that depend on each other. Read-your-writes guarantees a user sees their own updates, and eventual only promises replicas converge if writes stop. I pick the weakest model the feature can tolerate, because stronger models cost latency and availability.

Could you say this in an interview?

From strongest to weakest (single-object models, as Jepsen defines them).

  • Linearizable. Every operation appears to take effect atomically at some point between its start and end, consistent with real-time order: if A completes before B begins, B sees A's effect. Needed for things like a lock, a unique username or "the last item in stock".
  • Sequential. All processes see operations in the same total order, and each process's own operations stay in order, but that order does not have to match real time.
  • Causal. Operations that are causally related (a reply after the message it answers) are seen in that order by everyone; unrelated operations can be seen in different orders.
  • Read-your-writes. If a process writes and then reads, the read reflects the write. Jepsen notes that it says nothing about other processes seeing the write.
  • Eventual. If no new writes arrive, replicas eventually return the same value. Werner Vogels' article describes this and the session guarantees (read-your-writes, monotonic reads) that make eventual consistency practical to program against.

Where you see them in practice. DynamoDB offers eventually consistent reads by default and strongly consistent reads as an option on tables. Many apps use a leader for read-your-writes paths and replicas for the rest, as described in the replication question.

How this relates to CAP. The "C" in CAP means linearizability. Jepsen also notes which models can stay available during a network partition: causal and read-your-writes are "sticky available", meaning a client that keeps talking to the same non-faulty server can make progress, while linearizable and sequential cannot be totally or sticky available.

Common mistakes interviewers listen for.

  • Using "strong consistency" without saying which guarantee.
  • Confusing consistency models with ACID consistency or with transaction isolation levels; serializability is about multi-object transactions, linearizability about single objects.
  • Choosing one model for the whole system instead of per feature. Search staleness is discussed in eventual consistency for price and stock in search.
Sources (7)
  1. Jepsen: Consistency modelsjepsen.io
  2. Jepsen: Linearizabilityjepsen.io
  3. Jepsen: Sequential consistencyjepsen.io
  4. Jepsen: Causal consistencyjepsen.io
  5. Jepsen: Read your writesjepsen.io
  6. Werner Vogels: Eventually consistentallthingsdistributed.com
  7. AWS: DynamoDB read consistencydocs.aws.amazon.com
Previous
Next