Read Consistency in Distributed Databases: The Latency You Pay

Distributed databases offer several read modes, and the differences between them are latency and guarantee, not correctness in the abstract. A quorum read waits for a majority of replicas to agree; a leader read goes to one node; a follower read accepts possibly stale data for lower latency and better read scaling. Using one mode for everything means either paying latency you did not need or accepting staleness you cannot tolerate.

The short version: classify reads by what happens if they are stale. Then route each class to the cheapest mode that satisfies it, and measure the latency of each mode under real load rather than in a benchmark.

The three guarantees, plainly

Read-your-writes guarantees that a client sees its own write immediately. Monotonic reads guarantee a client does not go backwards in time. Linearizability guarantees every reader sees the latest committed write. Each requires progressively more coordination, and coordination is latency.

For an application, the practical question is which guarantee each screen needs. A user who just edited their profile must see the edit; another user browsing that profile can tolerate a second of delay; an analytics dashboard can tolerate minutes. Those are three different read classes with three different costs.

Where the latency actually comes from

Quorum reads add a round trip to the slowest replica in the quorum and any repair work. Cross-region reads add the distance between the client and the coordinating node. Follower reads remove the trip to the leader but can be served from a replica that has not applied the latest write.

Because these costs are additive, a single query that is both quorum and cross-region is several times slower than a local follower read. That is why a mixed workload shows a latency distribution with two humps: the cheap path and the consistent path, and users experience whichever their screen uses.

Session guarantees in practice

Read-your-writes is usually implemented by pinning a session to the leader for a window after a write, or by passing a consistency token (a log position or timestamp) that the read must satisfy. The token approach is cheaper because it allows any replica that has caught up, and it degrades gracefully: if no replica has caught up, the read waits or escalates rather than silently returning stale data.

Pin-for-a-window is simpler and less precise, and it has a subtle failure: if the write fails and the client retries elsewhere, the pin may point at the wrong node. Prefer the token where the database exposes one; it is exactly the mechanism designed for this.

Stale reads are a product decision

Allowing a follower read means deciding what a user sees when the data is a second old. On a product listing, nothing. On an account balance, a support ticket. The decision belongs in the product spec, not in a database configuration file, and it should be written per feature.

A cheap pattern is optimistic display with a short reconciliation: show the possibly-stale value immediately, then refresh after a moment. This keeps perceived latency low and converges, and it is honest as long as the UI does not invite an irreversible action based on the stale value.

Measuring the trade

Run each read class against each mode under production-like concurrency and record p50, p95, and p99, plus the load impact on the primaries. The interesting number is usually p99, because the consistent path’s tail is what users notice during incidents and what capacity planning misses.

Also measure the staleness distribution for follower reads: how old is the data, at p50 and p99, under normal and catch-up conditions. A replica that is two seconds behind normally can be two minutes behind after a disruption, and that changes whether the guarantee is acceptable.

A worked example of routing reads by class

A marketplace database runs three replicas per region. Initially every read is a quorum read from the coordinating node, giving p99 latency of 180 milliseconds and a primary that is saturated by read coordination. Splitting reads into classes changes the picture quickly.

Product listing and search results, which tolerate seconds of staleness, move to local follower reads: p50 drops to 12 milliseconds and primary load falls by sixty percent. A seller’s own inventory view keeps read-your-writes through a consistency token, costing about 30 milliseconds locally. Checkout keeps a quorum read on the primary, at 180 milliseconds, but it happens once per order rather than once per page view.

The overall latency profile now has three visible tiers instead of one, the primary has capacity again, and the only user-visible change is that a listing occasionally shows a price a second old, which no customer has ever noticed.

What to check before you commit

  • Classify reads by tolerance: must-see-own-write, can-be-seconds-old, can-be-minutes-old.
  • Route each class to the cheapest mode that satisfies it.
  • Use consistency tokens rather than time-based leader pinning where available.
  • Measure p99 latency per mode under real concurrency.
  • Measure staleness distribution for follower reads, including catch-up periods.
  • Write the staleness tolerance into the product spec per screen.

Consistency is a dial with a price, and the price is paid per query. Turning it per read class instead of per database is the single change that most often cuts both latency and primary load without breaking anything a user can see.

A final operational note: make the read mode visible in tracing. Tagging each query with the consistency class it requested turns a latency investigation from guesswork into arithmetic, because you can see immediately whether the slow tail is the consistent path doing its job or a cheap read that has been accidentally routed to the primary. Most regressions in this area are routing mistakes, and routing mistakes are invisible without the tag.

Review the routing quarterly against the product spec, because features accumulate staleness tolerance informally. A screen that once required a fresh read often stops needing it after a redesign, and the only way to reclaim that latency is the same tag, read by a human, once in a while.

Leave a Comment