Notesdistributed🌱 seedling
Causal Consistency
Also: Causally Consistent · Causal+ Consistency · Real-Time Causal Consistency
If one operation could have influenced another, every replica shows them in that order; concurrent operations may appear in different orders. It is about the strongest model that stays available during a partition.
Why it exists
The anomalies users notice are causal: a reply before its post, a photo visible to someone just removed from the audience. Fixing them doesn't need a global order, only cause before effect, and that can be done without cross-region round trips.
How it works
- Causality is Happens-Before: same client in sequence, or a read of a write followed by a later operation.
- Each write carries its dependencies (a Version Vector, or the versions the client has observed).
- A replica delays making a write visible until everything it depends on is visible.
- Implies the session guarantees: Read-Your-Writes Consistency, Monotonic Reads, monotonic writes, writes-follow-reads.
- Real-time causal, a slightly stronger variant, is proved the strongest model in an always-available, convergent system.
Trade-offs
| Gains | Costs |
|---|---|
| no causal anomalies | dependency metadata on every write |
| local reads and writes; sticky available | concurrent writes still conflict and need merging |
| no global coordination | only sees causality that flows through the store |
In practice
- MongoDB: causally consistent sessions pass cluster and operation times between operations so a session reads its own writes in causal order.
- Typical use: social feeds, comments, collaborative apps across regions.
Pitfalls
- Hidden channels: a phone call or a message queue carries causality the database never saw.
- Clients that hop replicas lose the "sticky" availability; the session must carry its dependency state.
Connections
- Part of
- Consistency Model
- Learn first
- Happens-Before
- In real systems
- MongoDB
Recall
These cards are also in your review deck, scheduled with spaced repetition.