Course contentsShow
← Computer Science
Lesson 2613 of 2,87258. Distributed Systems BasicsFree lesson

Causal Consistency

Study causal consistency: operations with causal relationships are seen in the same order by all processes.

Causal Consistency

What You'll Learn

You'll understand how causal consistency ensures that operations with cause-and-effect relationships are seen in the same order by all processes, while unrelated operations can appear in different orders.

The Core Idea

Causal consistency is weaker than sequential consistency but respects the natural flow of cause and effect. If operation A causally influences operation B (meaning B depends on or follows from A), then all processes must see A before B. However, operations that aren't causally related—called concurrent operations—can be observed in different orders by different processes.

Think of it like gossiping in a group chat: if Alice posts "I'm getting pizza," and Bob replies "Save me a slice!", everyone must see Alice's message before Bob's reply (they're causally related). But if Carol simultaneously posts about her cat in a different conversation, some people might see Alice's message first, others might see Carol's first—and that's fine because those messages aren't causally connected.

Three Causal Relationships

  1. Local order: Operations on the same process are causally ordered
  2. Read-write dependency: If you read a value, then write based on it, there's a causal link
  3. Transitivity: If A causes B, and B causes C, then A causes C

Causal consistency is attractive because it's more performant than sequential consistency (less coordination needed) while still maintaining intuitive ordering for related operations.

Example Scenario

  • Process P1 writes X=1
  • Process P2 reads X=1, then writes Y=2 (causally dependent on X=1)
  • Process P3 must see X=1 before Y=2
  • But P4 writing Z=3 (unrelated) can be seen in any order relative to X or Y

Key Takeaway: Causal consistency preserves cause-and-effect relationships across all processes while allowing flexibility for concurrent, unrelated operations—balancing correctness with performance.