Course contentsShow
← System Design
Lesson 1395 of 1,91934. Data Replication StrategiesFree lesson

Causal Consistency

Preserve cause-and-effect relationships between operations while allowing concurrent writes to diverge.

Causal Consistency

What you'll learn: How to preserve cause-and-effect ordering across replicas while allowing unrelated operations to proceed independently.

The Core Idea

Causal consistency ensures that if one operation causally depends on another (B happened because of A), all replicas see them in that order. However, concurrent operations with no causal relationship can be seen in different orders by different replicas.

Think of it like a group chat: If Alice sends "What's your favorite color?" and Bob replies "Blue!", everyone must see Alice's question before Bob's answer—that's causal order. But if Carol simultaneously messages "Anyone free tonight?", different members might see Carol's message before or after Alice's question, since they're unrelated.

Why It Matters

Causal consistency sits between eventual consistency and strong consistency:

  • Stronger than eventual: prevents confusing scenarios where replies appear before questions
  • Weaker than linearizability: doesn't force a global order on concurrent, unrelated writes
  • Enables collaborative systems (documents, social feeds) to feel "right" without expensive coordination

How It Works

The system tracks causal dependencies using mechanisms like version vectors or Lamport timestamps. When you read value X then write Y, the system remembers that Y depends on X. Replicas delay showing Y to any client until they've also shown X.

Operations with no dependency chain can arrive and display in any order—maximizing availability and performance.

Key Takeaway: Causal consistency preserves the "happened-before" relationship so users never see effects before causes, while allowing independent operations to propagate freely across replicas without coordination overhead.