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

Session Consistency

Providing read-your-writes and monotonic reads within the scope of a single client session.

Session Consistency

What you'll learn: How distributed systems guarantee consistent views of data for the duration of a single client session, combining multiple consistency guarantees into a cohesive user experience.

What is Session Consistency?

Session consistency is a consistency model that bundles several weaker guarantees together to provide a coherent experience within a single client session. Specifically, it typically guarantees both read-your-writes and monotonic reads for as long as a client maintains its session with the system.

Think of it like having a personal shopping assistant who remembers everything you've done during your visit to a store. Even if different store employees handle different parts of your order (distributed replicas), your assistant ensures you always see the items you've added to your cart (read-your-writes) and that time never moves backward in your order history (monotonic reads).

How It Works

When a client establishes a session, the system tracks a consistency token or session identifier. This token moves with the client's requests, ensuring:

  1. Read-your-writes: Any data you write is visible in subsequent reads within your session
  2. Monotonic reads: You never see older versions of data than you've already observed in this session

The session acts as a boundary. Outside your session, other clients might see different (possibly stale) data, but your view remains consistent with your own actions.

Why Session Consistency Matters

Session consistency strikes a practical balance: it's cheaper than strong consistency (no global coordination needed) but provides enough guarantees for most interactive user experiences. Web applications often use session-based consistency to ensure users see their own updates immediately without forcing expensive global synchronization.

Key Takeaway:
Session consistency binds read-your-writes and monotonic reads to a single client session, ensuring each user experiences a coherent view of data without requiring strong global consistency.