seniorCosmos DB

The Mechanics of Global LSN and Vector Clocks in Session Consistency Guarantees

Updated Apr 28, 2026

Short answer

Session consistency uses a 'Session Token' (effectively a vector clock or LSN) passed between client and server to ensure read-your-own-writes within a specific version boundary.

Deep explanation

When a client writes to Cosmos DB under Session consistency, the server returns an x-ms-session-token. This token contains the LSN (Log Sequence Number) of that specific write. In subsequent reads, the client sends this token back. The server ensures that the replica processing the read has at least reached that LSN. If the replica is lagging, the server waits or routes to a more up-to-date replica. This provides a 'Monotonic Read' guarantee for that specific client without the high cost of Strong consistency.

Unlock with a Pro subscription to view this section.

View pricing

Real-world example

No real-world example available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Common mistakes

No common mistakes listed yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Follow-up questions

No follow-up questions available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

More Cosmos DB interview questions

View all →