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

Causal Consistency Fundamentals

Preserving the order of causally related operations while allowing concurrent operations to be seen in any order.

Causal Consistency Fundamentals

What you'll learn: How causal consistency ensures operations that are logically connected maintain their order while letting independent operations happen freely.

The Core Idea

Causal consistency sits between strong and eventual consistency, preserving cause-and-effect relationships while allowing flexibility everywhere else. If operation A influences operation B (a causal relationship), all replicas must see A before B. However, if operations X and Y happen independently (they're concurrent), different replicas can see them in any order.

Understanding Causality

Think of a conversation thread:

  • Alice posts: "Should we order pizza?"
  • Bob replies: "Yes, pepperoni please!"

Bob's reply depends on Alice's question—that's causality. Every system must show Alice's post before Bob's reply, or Bob's message makes no sense.

But if Carol simultaneously posts "Traffic is terrible today" in a different thread, it's concurrent with the pizza conversation. Some users might see Carol's post first, others might see the pizza discussion first—neither order breaks logic because these operations don't influence each other.

Why It Matters

Causal consistency uses vector clocks (which you've learned) to track dependencies. When a write happens, the system records what prior operations the writer had seen. Replicas then ensure causally-related operations appear in the correct order during reads.

This model avoids the performance cost of strong consistency (no global coordination needed for concurrent operations) while preventing confusing scenarios like seeing replies before questions.

Key Takeaway: Causal consistency guarantees that cause always appears before effect across all replicas, while concurrent operations can be reordered freely—preserving logical correctness without sacrificing too much performance.