Course contentsShow
← System Design
Lesson 537 of 1,91915. Consistency ModelsFree lesson

Writes-Follow-Reads Consistency

Explore writes-follow-reads: a write is guaranteed to happen after any reads the client has seen before.

What You'll Learn

You'll learn what writes-follow-reads consistency guarantees and how it prevents certain ordering anomalies in distributed systems.

The Core Idea

Writes-follow-reads consistency (also called "session causality") ensures that if a client reads some data and then performs a write, that write is guaranteed to happen after the values the client observed during the read. In other words, your writes must respect the causal history of what you've already seen.

This is about preserving causality: if you read something that influenced your decision to write, the system ensures your write doesn't appear to happen "before" what you read.

Why This Matters

Imagine you're moderating a forum:

  1. You read a post that contains spam
  2. Based on that read, you write a "delete post" command

Writes-follow-reads guarantees that your delete operation will be ordered after the post you read. Without this guarantee, in a distributed system with replication lag, another replica might process your delete before it even receives the original post—making your action appear nonsensical or causing the post to reappear later.

How It Relates to Other Guarantees

You've already learned about monotonic writes (your writes stay ordered) and monotonic reads (you don't go backward in time when reading). Writes-follow-reads adds a third dimension: ensuring writes respect the causal chain of reads that preceded them.

This is particularly important in systems where users make decisions based on what they see, then act on those decisions.

Key Takeaway: Writes-follow-reads consistency ensures that any write operation is guaranteed to occur after all the data versions the client has previously read, preserving causal ordering between reads and subsequent writes.