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

Writes-Follow-Reads Consistency

Ensuring that writes are ordered after any reads that causally precede them from the same client.

Writes-Follow-Reads Consistency

What You'll Learn

You'll discover how to ensure that when a client writes data based on something it just read, that write respects the causal order of the read.

The Core Idea

Writes-Follow-Reads (also called "session causality") guarantees that if a client reads a value and then performs a write based on that read, the write will be ordered after the read in the system. This prevents the write from appearing to happen "before" the data it was based on.

Think of it like replying to an email: your reply should never appear in someone's inbox before the original email you're responding to. That would be confusing and violate causality!

Why It Matters

Without this guarantee, strange things can happen:

  • You read a post with 10 likes
  • You write a comment: "Wow, 10 likes already!"
  • Another user sees your comment but the post shows 8 likes (they read from a less-updated replica)

This violates causality — your comment references information that "doesn't exist yet" from their perspective.

How It Works

The system tracks which data version the client read, then ensures any subsequent write from that client is applied only after that read's version has propagated. This often uses:

  • Version numbers or timestamps attached to reads
  • The client sending the version it read when making writes
  • Replicas refusing writes until they've seen that read version

Key Takeaway: Writes-Follow-Reads ensures your writes are always causally ordered after the reads that informed them, preventing confusing "time travel" scenarios where effects appear before their causes.