The interview problem

Practice prompt

A user saves a profile, refreshes and sees an older version because requests reach different replicas. Provide session read guarantees without sending every read to the primary.

Original practice, not a reported company interview. All scenarios and worked numbers are illustrative. Interview date: not applicable. Sources retrieved September 30, 2026.

1. Scope and assumptions

Assume one ordered replication history per shard and a verifiable applied position. Read-your-writes and monotonic reads are session guarantees, not globally linearizable reads.

2. Worked approach

session position
  → timeline validation
  → applied-position routing
  → bounded wait or explicit failure

Return a commit-position token after a successful write and include the latest observed position in subsequent session reads. A replica serves only after applying at least that position; otherwise wait within a deadline or route to a sufficiently current replica or primary. Return a new token representing the served snapshot.

Bind tokens to the correct shard and replication timeline, and authenticate them or validate their bounds so a forged far-future token cannot create indefinite waiting. After failover, reject or translate tokens using authoritative history information. For multi-shard pages, a vector or another explicit consistency contract is required; one scalar position from one shard does not cover all data.

3. Calculate the example

A session has observed position 120. Replica A has applied through 118 and replica B through 125. B can meet the minimum-position check; A must wait or decline. If A applies two positions per millisecond in this invented example, catching up takes about 1 ms, but real log positions are not uniform work units. A 50 ms wait budget must be enforced by elapsed time rather than guessed from position distance.

4. Failure cases and trade-offs

A token from an old primary timeline may not be comparable after failover. Losing session state loses the guarantee unless the client retains it. A replica reporting received log position rather than applied position can return stale values despite appearing caught up.

Primary-only reads simplify semantics at higher primary load. Token-based routing improves read distribution but adds metadata and lag-related latency. The guarantee can intentionally fail closed when no replica meets the bound rather than silently returning older data.

5. Validate the result

Alternate reads across lagging replicas after writes, restart clients and simulate timeline changes. Verify versions never regress within the stated session and that wait time is bounded. Test cross-shard pages separately.

6. Interview follow-ups and self-review

What happens when the user opens another device? Can a session token survive a failover that lost writes?

Reward applied-position checks, precise guarantee scope, timeline handling and bounded waiting.

Sources and related practice

Technical reference: www.postgresql.org — Replication/standby background; session-token protocol is an original design.

Exact publication/update date not established in this review. Retrieved September 30, 2026. This reference supports the named technical concept; the proposed workflow and examples are original, not a documented vendor implementation or interview report.

Continue with Fail over a regional write service safely; Design a cross-shard transaction coordinator.

Continue your preparation

Choose a connected learning path or browse more System design questions. Read our editorial method and attribution policy.