Session Consistency Models
You'll learn how to scope consistency guarantees to individual client sessions for a practical balance between performance and predictability.
What Are Session Consistency Models?
In distributed systems, enforcing strong consistency everywhere is expensive—it requires coordination across nodes, increasing latency. However, session consistency offers a middle ground: instead of guaranteeing consistency globally, you guarantee it per client session.
Think of a session like your personal conversation with a system. Within your session, the system promises certain behaviors (like Read-Your-Writes or Monotonic Reads), but it doesn't guarantee those same behaviors across different clients or sessions. This lets the system optimize for performance while still giving each user a reasonable, predictable experience.
How It Works
A session is typically tied to a single client's connection or authenticated user. The system tracks metadata (like timestamps, version vectors, or last-read positions) for that session. When you read or write:
- Within your session: The system honors guarantees like "you'll always see your own writes" or "you won't see data go backward in time."
- Across sessions: No such guarantees—other users might see stale data or different orderings.
Example Scenario
Imagine you update your profile picture. With session consistency:
- You immediately see your new picture (Read-Your-Writes within your session)
- Your friend might still see the old picture for a few seconds (eventual consistency across sessions)
The system doesn't force all nodes to synchronize before returning your update, but it routes your subsequent reads to nodes that have your writes.
Why Use Session Consistency?
It's a pragmatic choice: you get decent user experience without the performance hit of strong global consistency. Most users care about their own view being coherent, not whether everyone sees exactly the same thing at the same instant.
Key Takeaway: Session consistency scopes guarantees to individual client sessions, delivering predictable behavior per user while allowing the system to optimize globally for availability and performance.