← The Books

Probably Up to Date

When a store reads from only some of its copies, how likely is an answer to be out of date, and by how much? Can we promise that it is probably not?

We find out by exploring how the libraries of the scholars' coast, each entry answered for by three of them, worked out the odds that a reader who asks only a few is handed the newest version.

We find out by following the probabilities directly: a data item stored on a few replicas, a write acknowledged by some of them, a read answered by some others, and the exact odds that the answer is current.

After Peter Bailis, Shivaram Venkataraman, Michael J. Franklin, Joseph M. Hellerstein and Ion Stoica, Probabilistically Bounded Staleness for Practical Partial Quorums, 2012

A small library seen from its terrace: a tiled roof over a porch of plain columns, and in front a scholar and a librarian comparing two copies of a scroll, leaves of a bush at the right
Where this book sits
Draws on
  • Epidemic Algorithms for Replicated Database MaintenanceDemers et al. 1987 · Spreading by Word of Mouth
  • Probabilistic Quorum SystemsMalkhi, Reiter, Wool & Wright 2001
  • On the Availability of Non-Strict Quorum SystemsAiyer, Alvisi & Bazzi 2005
  • Dynamo: Amazon’s Highly Available Key-Value StoreDeCandia et al. 2007

Each link is an idea one paper took from another. Point at one, or tap it, to read how.

a paper this book retells a paper retold in another book a paper outside the series

The coast from high above: hills covered in olive groves, a long inlet of the sea winding in at the left, more inlets, the open sea and islands beyond
The scholars' coastThe model

An entry and its three home librariesA data item and its three replicas

On the scholars' coast, libraries answer readers from their own copies of the compendium, and live with copies that differ while couriers are on the road.* Every library keeps the whole compendium, but each entry has three home libraries that answer for it: a revision goes to them, and a reader who wants the newest version asks them.In this system, replicas answer clients from whatever copy they hold, accepting that copies may differ while messages are still in transit. Rather than copying every item to every machine, each item is stored on three designated replicas.

Three home librariesEach entry has three home libraries that answer for it (N = 3). The other libraries learn of a revision later, by the spread.Three replicasEach item is kept at three designated replicas (N = 3) and nowhere else.
Couriers on the roadA new version goes by courier to all three home libraries at once, and each courier takes a slightly different time.Messages in flightA new version is sent to all three replicas at once, and each message takes a slightly different time.
The newest reply winsA reader sends couriers to all three home libraries and takes the newest version among the first R replies that come back.The newest reply winsA client sends requests to all three replicas and takes the newest version among the first R replies that return.
Who answers for the entryWho holds the item

An entry and its home librariesA data item and its replicas

Every entry has three home libraries (N = 3) that answer for it. As everywhere on the coast, each version carries a tally, the day and hour it was written, and of two versions the larger tally is the newer.Every copy of a given item lives at its three replicas (N = 3). Each version carries a timestamp, and whenever two versions are compared, the larger timestamp is the newer.

A scholar who finishes a new version sends three couriers at once, one to each home library. Each home library that receives it puts it in its copy and sends a courier back to say so. As soon as W home libraries have answered, the writer announces the version (commits the write). The couriers still on their way to the other home libraries do not turn back; they deliver the version when they arrive.When a writer finishes a new version, it immediately sends three messages, one to each replica. Each replica that receives the version stores it and sends an acknowledgment back. As soon as W replicas have answered, the writer commits the write. Importantly, the messages still on their way to the remaining replicas are not recalled; they keep going and deliver the version when they arrive.

A reader who wants to consult the entry likewise sends a request to all three home libraries, waits for the fastest R replies, and takes whichever copy among them has the largest tally.When a client wants to read the item, it likewise sends a request to all three replicas, waits for the fastest R replies to come back, and takes whichever copy among those R replies has the largest timestamp.

Two numbers therefore govern the coast's speed and safety: how many answers (W) the writer waits for before announcing the version, and how many replies (R) the reader waits for before reading.Two numbers therefore govern the system’s speed and safety: how many acknowledgments (W) the writer waits for before committing, and how many replies (R) the client waits for before returning an answer.

Inside a library's reading room from behind its desk: the librarian sits checking one scroll against another while a scholar waits in the bright doorway with a roll in his hand
Certainty, and its price

How many to wait for

A writer who waited for all three home libraries (W = 3), or a reader who waited for all three replies (R = 3), would be held up by every slow courier and every closed library.If a writer waited for all three replicas (W = 3) or a client waited for all three replies (R = 3), every single slow message or crashed replica would bring work to a halt.

Waiting for fewer libraries is faster and survives a closed door. The danger is that if W and R are too small, the home libraries that answered the writer and the home libraries that answered the reader might not overlap at all.Waiting for fewer replicas is faster and survives a crashed replica. The danger is that if W and R are too small, the replicas that answered the writer and the replicas that answered the client might not overlap at all.

Three home libraries, one new version choose the two numbers, then let a reader askThree replicas, one new version choose the two numbers, then let a client read

The writer waits for
The reader takes the firstThe client takes the first

Gold home libraries hold the new version. Ringed home libraries are the ones the reader hears from first.Each lane is one process, with real time running left to right: the writer W, the three replicas, and the client C. Dashed arrows are still in transit. The writer commits once its acknowledgments are in; the client reads at that moment and takes the first replies.

The rule the Chamber has always usedThe quorum rule

When R + W > N, the two groups must share at least one home libraryWhen R + W > N, the two groups must share at least one replica

North of the coast, on the island's two summits, the Chamber and the Tholos rely on majority overlap: of four or five members, any two majorities share a member.* The rule here is more general. With N = 3 home libraries, whenever R + W > 3 (for instance W = 2 and R = 2), the W libraries that hold the announced version and the R libraries that answer the reader share at least one library. The reader takes the largest tally among the replies, so the reader is sure to get the announced version or a newer one.Majority overlap is the oldest idea in the series: out of three or five members, any two majorities share at least one member.* Here the rule is even more general: with N = 3 replicas, as long as R + W > 3 (for instance, W = 2 and R = 2), the W replicas that hold the committed version and the R replicas that answer the client must share at least one replica. Because the client picks the largest timestamp among its R replies, it is guaranteed to get the committed version or an even newer one.

Proof · that R + W > N forces every read quorum to meet every write quorum

Let there be N replicas, a write quorum QW of size W and a read quorum QR of size R, both subsets of the same N replicas. Claim. If R + W > N, the two quorums share a replica.

  1. This is the standard property of strict quorums, which the paper recalls in §2. Let there be N replicas, a write quorum QW of size W and a read quorum QR of size R, both subsets of the same N replicas.
  2. |QW ∪ QR| ≤ N, since both are subsets of a set of size N.
  3. |QW ∩ QR| = |QW| + |QR| − |QW ∪ QR| ≥ W + R − N.
  4. If R + W > N, the right side is at least 1, so the two quorums share a replica. That replica holds the committed write, and a read that returns the value with the greatest version among its responses returns that write or a later one.∎

Yet with three home libraries, many choose W = 1 and R = 1 on purpose: waiting for only the fastest answer and the fastest reply makes writing and reading as quick as the nearest, least busy library. On the coast, waiting for one and asking one (W = 1, R = 1) is called the quick way.Yet in practice, practitioners with three replicas very often configure W = 1 and R = 1 on purpose, because waiting for only the single fastest acknowledgment and the single fastest reply makes both writing and reading as fast as the nearest, least-busy replica. Waiting for one and asking one (W = 1, R = 1) is the quick way.

The plainest case

When the groups miss each other

Suppose a reader asks at the exact instant a version is announced, before the couriers to the remaining N − W home libraries have arrived, and suppose the R libraries that answer the reader first are a uniform random subset of the N home libraries.Suppose a client reads at the exact instant a version is committed, before the messages to the remaining N − W replicas have arrived, and suppose the R replicas that answer the client first are a uniform random subset of the N replicas.

With N = 3 home libraries and the quick way (W = 1, R = 1), only one home library holds the new version at the moment of announcement, while two still hold the old one. A reader who takes one random reply therefore misses the new version 2 times out of 3 (66.7%).With N = 3 replicas and the quick way (W = 1, R = 1), only one replica holds the new version at the moment of commit, while two still hold the old one. A client that takes one random reply therefore misses the new version 2 times out of 3 (66.7%).

Earlier theory on probabilistic quorums pointed out that if N is large and W and R scale with N (say, a third of the libraries each), two random subsets of size N/3 almost never miss each other.Earlier theory on probabilistic quorums pointed out that if N is large and W and R scale with N (say, a third of the replicas each), two random subsets of size N/3 almost never miss each other.

The chance of an old copy about a third of the home libraries waited for, and a third askedThe chance of an old copy about a third of the replicas waited for, and a third asked

The page works these out from the count of the ways the reader's home libraries can all lie among those the version has not reached.The page works these out from the count of the ways the client’s replicas can all lie among those the version has not reached.

Proof · that the probability of a read missing the last write is C(N − W, R) / C(N, R)

Let N be the number of replicas, W the write quorum size and R the read quorum size, the W replicas written and the R replicas read each chosen uniformly at random; C(n, r) is the number of subsets of size r of a set of size n. Claim. The probability ps that the read quorum misses the write quorum is C(N − W, R) / C(N, R).

  1. This is Equation 1 of §2.1, with the paper's assumption that the W replicas written and the R replicas read are each chosen uniformly at random.
  2. The read quorum is one of the C(N, R) subsets of size R, each equally likely.
  3. The read misses the write quorum exactly when every one of its R members lies among the N − W replicas not written to. There are C(N − W, R) such subsets.
  4. So ps = C(N − W, R) / C(N, R). For N = 3, R = W = 1 this is 2/3; for N = 100, R = W = 30 it is about 1.88 × 10−6, as the paper states.∎

That works well when an entry has 100 home libraries, where W = R = 30 misses fewer than twice in a million reads. But real stores keep three copies of an item, not 100, and still find the quick way well behaved. Two kinds of leeway explain it: leeway in versions (k) and leeway in time (t).That combinatorial effect is great if an item has 100 replicas, where W = R = 30 misses fewer than twice in a million reads. Real systems, however, keep N = 3 copies of each item, not 100, and operators still find W = 1, R = 1 well behaved when N = 3. Two kinds of leeway explain it: leeway in versions (k), and leeway in time (t).

Leeway in versionsLeeway in versions

How many versions behindHow many versions behind

First, suppose an entry is revised often, and a reader does not need the very newest version, only one of the newest k (what the paper calls k-staleness).First, suppose an item is updated frequently and a client does not strictly need the single newest version, as long as the copy returned is within the newest k versions (what the paper calls k-staleness).

Each of the last k announced versions was written to W home libraries. A reader's R replies are older than all k of those versions only if the reader's group misses the write group of the newest version, and misses that of the second newest, and so on for all k. If each write group is missed independently with probability ps, the chance of missing all k is psk, which falls exponentially with k.Each of the last k committed versions was written to W replicas. A client’s R replies return something older than all k of those versions only if the client’s group misses the write group of the newest version, and misses the write group of the second-newest version, and so on for all k versions. If each write group is independent with miss probability ps, the chance of missing all k of them is simply psk, which drops exponentially with k!

One of the newest few three home libraries, the reader takes one replyOne of the newest few three replicas, the client takes one reply

The writer waits for

Worked out from the rule: one chance of a miss for each version that will do, all multiplied together.Worked out from the rule: one chance of a miss for each version that will do, all multiplied together.

Proof · that PBS k-staleness is psk = psk

Let ps = C(N − W, R) / C(N, R) be the probability that a read quorum misses one write quorum, and let k be the number of versions a reader will accept. Claim. A read returns a value more than k versions old with probability psk = psk.Let ps = C(N − W, R) / C(N, R) be the probability that a read quorum misses one write quorum, and let k be the number of versions a client will accept. Claim. A read returns a value more than k versions old with probability psk = psk.

  1. This is §3.1 for quorums that do not expand. A read returns a value within k versions of the latest committed version exactly when its read quorum intersects at least one of the write quorums of the last k committed versions.
  2. Treat the k write quorums as independent, each missed by the read quorum with probability ps = C(N − W, R) / C(N, R).
  3. The read quorum misses all k with probability psk, so psk = psk and the read is within k versions with probability 1 − psk.
  4. With N = 3, R = W = 1, ps = 2/3, so 1 − (2/3)k is 5/9 for k = 2, 0.704 for k = 3, 0.868 for k = 5 and 0.983 for k = 10. With W = 2, ps = 1/3 and the values are 2/3, 8/9 and 0.996 for k = 1, 2 and 5, as the paper's examples give.
  5. For expanding quorums the paper notes this is an upper bound on the probability of staleness, since writes only reach more replicas with time.∎

Tolerating a few versions of staleness also reduces the load on the libraries: because a smaller R and W suffice to hit high confidence over k versions, each home library has to handle fewer couriers per read and write.Tolerating a few versions of staleness also reduces the load on the replicas: because a smaller R and W suffice to hit high confidence over k versions, each replica has to handle fewer messages per read and write.

Even more important than leeway in versions, however, is what happens in the moments after a version is announced, while the remaining couriers finish their walk.Even more important than leeway in versions, however, is what happens in the moments after a version is committed, while the remaining messages finish their journey.

Leeway in time

How long until it shows

The writer sent couriers to all three home libraries at the start, though the version was announced as soon as the fastest W answered. Moments after the announcement, the couriers to the other N − W home libraries arrive too (expanding quorums).Remember that the writer sent messages to all three replicas at the start, even though it committed as soon as the fastest W answered. Moments after the commit, the messages to the other N − W replicas arrive too (expanding quorums).

The paper defines t-visibility as the probability that a reader whose request starts at time t after a version is announced receives that version (or a newer one).The paper defines t-visibility as the probability that a client that starts its read at time t after a version is committed receives that version (or a newer one).

At the moment of announcement (t = 0), at least W home libraries hold the version. A little later the number holding it has grown from W toward N. Once all three hold it, even a reader who asks only one library (R = 1) is certain to get it.At the exact instant of commit (t = 0), at least W replicas hold the version. A short time t later, the number of replicas c holding the version has grown from W toward N. Once all N = 3 replicas hold it, even a client that asks only R = 1 replica is 100% certain to get it!

Two things to note

A newer version ends the questionA newer version ends the question

If an even newer version is announced before the first version's couriers have finished arriving, a reader who receives the newer version is completely up to date.If an even newer version is committed before the first version’s messages have finished arriving, a client that receives the newer version is completely up to date.

Two things to note

Not yet announced is not staleNot yet committed is not stale

If a reader happens to read a version that has already reached one home library but has not yet been announced by its writer, that copy is ahead of the last announced version, not stale.If a client happens to read a version that has already reached one replica but has not yet been committed by its writer, that copy is ahead of the last committed version, not stale.

Proof · that the probability of a stale read t after commit is a sum over how many replicas hold the write

Let qc(t) be the probability that exactly c replicas hold version v at time t after v commits, for c from W to N. Claim. The probability of a stale read at time t is pst = Σc=WN qc(t) · C(N − c, R) / C(N, R).

  1. This is §3.4. Let qc(t) be the probability that exactly c replicas hold version v at time t after v commits, for c in [W, N]; at commit exactly W do with certainty, so qW(0) = 1.
  2. Conditional on exactly c replicas holding v, a read quorum chosen uniformly misses all of them with probability C(N − c, R) / C(N, R), by the argument of Equation 1.
  3. Summing over the possible c: pst = Σc=WN qc(t) · C(N − c, R) / C(N, R). The paper writes this with its distribution Pw(c, t) of the number of replicas reached; its printed Equations 4 and 5 differ from one another in the range of the sum and the sign of the difference, and the sum above is the quantity both mean.
  4. The paper notes that this assumes instant reads and instant commitment after the Wth copy arrives, so it is a conservative upper bound on the true probability of staleness. When the last k writes all happened at the same time the same argument gives the chance of missing all k as the kth power, the paper's ⟨k, t⟩-staleness.∎

Combining both kinds of leeway gives ⟨k, t⟩-staleness: the chance that a read begun t after commit returns one of the newest k versions. To compute t-visibility accurately, however, we have to look closely at the four courier journeys involved in a write and a read.Combining both kinds of leeway gives ⟨k, t⟩-staleness: the chance that a read begun t after commit returns one of the newest k versions. To compute t-visibility accurately, however, we have to look closely at the four message journeys involved in a write and a read.

A library on a headland seen from behind in the afternoon: a courier in blue walks round its side with a roll under his arm, the bay and a wooded island beyond
The couriers' journeysThe message journeys

The four legs

Every write-and-read pair involves four courier legs (which the paper calls the WARS model), and each leg takes a random transit time:Every write-and-read pair involves four message legs (which the paper calls the WARS model), and each leg takes a random transit time:

1. W. The version's way out from the writer to each home library.
2. A. The acknowledgment's way back from each home library to the writer.
3. R. The request's way out from the reader to each home library.
4. S. The copy's way back from each home library to the reader.
1. W. The write’s way out from the writer to each replica.
2. A. The acknowledgment’s way back from each replica to the writer.
3. R. The request’s way out from the client to each replica.
4. S. The response’s way back from each replica to the client.

A home library hands a stale copy to a reader whose request starts at time t after the announcement exactly when the request reaches it before the writer's courier with the version does. The reader's answer is stale only if every one of the fastest R replies came from a home library where the request outran the version.A particular replica i hands a stale copy to a client that starts its read at time t after the commit exactly when the client’s request reaches replica i before the writer’s message does. And the client’s overall answer is stale if and only if every one of the fastest R replies it receives came from a replica where the request outran the write.

A request that outruns the version the writer, one home library and the readerA request that outruns the write the writer, one replica and the client

  • W the writer · K one home library · R the readerW the writer · K one replica · R the client
  • 1 The writer sends the version. Its way out to this home library is slow.The writer sends the version. Its way out to this replica is slow.
  • 2 Enough other home libraries answer, and the writer announces it.Enough other replicas answer, and the writer commits it.
  • 3 A while later the reader sends a request. Its way out is quick.A while later the client sends a request. Its way out is quick.
  • 4 The request arrives first. The home library sends back the old copy.The request arrives first. The replica sends back the old copy.
  • 5 The version arrives, too late for this reader.The version arrives, too late for this client.

Because the announcement time wt is the W-th order statistic of W + A and the reader takes the R smallest round trips of R + S, there is no simple closed-form formula for the probability of a stale read at time t. Instead, the librarians compute the exact odds by Monte Carlo simulation: replaying the four legs tens of thousands of times using journey times drawn from the couriers' logbooks.Because the commit time wt is the W-th order statistic of W + A and the client takes the R smallest round trips of R + S, there is no simple closed-form formula for the probability of a stale read at time t. Instead, the exact odds are computed by Monte Carlo simulation: replaying the four legs tens of thousands of times using journey times drawn from measured latency logs.

Play it over ten thousand times three home libraries; every journey's time is drawn afreshPlay it over ten thousand times three replicas; every journey’s time is drawn afresh

The writer waits for
The reader takes the firstThe client takes the first
The version's way out, against the other three legsThe write’s way out, against the other three legs

Choose, then play.

Proof · that under WARS no read is stale when R + W > N

WARS names the four delays: W, from the coordinator to a replica for a write; A, the acknowledgment back; R, a read request to a replica; S, the response back. Let the write be sent at time 0, reach replica i at wi and be acknowledged at wi + ai; it commits at wt, the Wth smallest acknowledgment time. Claim. If R + W > N, a read begun at any t ≥ 0 after commit is not stale.

  1. This is the remark of §4.1. Let the write be sent at time 0, reach replica i at wi (a draw from W) and be acknowledged at wi + ai (a draw from A). The write commits at wt, the Wth smallest of these acknowledgment times.
  2. The W replicas whose acknowledgments came first each received the write at wi ≤ wt.
  3. A read begins t ≥ 0 after commit, so its request to replica i arrives at wt + t + ri (a draw from R), which is at least wi for each of those W replicas. Such a replica returns the write.
  4. The read takes the first R responses, which are R distinct replicas. If R + W > N they cannot all lie among the N − W other replicas, so at least one is among the W that hold the write, and the read is not stale.∎

The method of §5.1 for the general case: draw N samples from each of W, A, R and S; compute wt, the Wth smallest of the sums W[i] + A[i]; order the replicas by R[i] + S[i]; and count the read stale when each of the first R satisfies wt + R[i] + t ≤ W[i]. Repeating this many times gives the probability for each t.

To verify that this four-leg replay matches reality, the authors tested it against an instrumented Apache Cassandra cluster across 50,000 writes. The predicted t-visibility curve matched the measured staleness to within 0.28% on average.

The replay, run on real roadsThe replay, run on real networks

What the logbooks sayWhat the latency logs say

Running the four-leg replay reveals first of all which leg governs staleness: the version's way out (W), and especially how uneven (high-variance) it is.Running the four-leg replay reveals first of all which leg governs staleness: the write’s way out (W), and especially how uneven (high-variance) it is.

By the time the writer announces the version (wt = W1 + A1), the couriers carrying it to the other two home libraries have already been walking for that long. If all three walk at nearly the same pace, the other two arrive while the answer is still on its way back to the writer, so at the moment of announcement (t = 0) a reader using the quick way (W = 1, R = 1) already gets the new version 9 times in 10. Only when the way out is much slower or much more uneven than the other legs can a late courier still be on the road when a reader's request arrives.By the time the writer commits the version (wt = W1 + A1), the write messages to the other two replicas have already been travelling for wt. If all three write messages travel at nearly the same pace, the other two arrive while the acknowledgment is still travelling back to the writer, so at the very instant of commit (t = 0), a client using the quick way (W = 1, R = 1) already gets the new version 9 times out of 10! Only when W is much slower or much more variable than the other legs can a late write message still be in flight when a client’s request arrives.

The authors then replayed production latency distributions from LinkedIn (LNKD-SSD and LNKD-DISK), Yammer (YMMR), and wide-area networks (WAN).

Four coasts, the same three home libraries, the quick way the chance of the new version at the moment it is announcedFour networks, the same three replicas, the quick way the chance of the new version at the moment it is committed

These are the paper's measures. The page does not work them out.

What the logbooks showWhat the latency logs show

A long tail delays certainty

On the SSD coast (LNKD-SSD), immediate visibility at t = 0 is high (97.4%), because median writes are fast; yet because occasional straggler writes take much longer (a long tail), reaching 99.9% certainty takes longer than on more uniform paths.On the SSD network (LNKD-SSD), immediate visibility at t = 0 is high (97.4%), because median writes are fast; yet because occasional straggler writes take much longer (a long tail), reaching 99.9% certainty takes longer than on more uniform paths.

What the logbooks showWhat the latency logs show

More home libraries hurt the first moment, not the endMore replicas hurt the first moment, not the end

When writes are slow (LNKD-DISK, where disk writes dominate network time), increasing N from 2 to 10 with W = R = 1 lowers immediate visibility at t = 0 from 58% to 21%, because only one of ten libraries has finished writing at commit. Yet the time to reach 99.9% visibility increases by only about 20%.When writes are slow (LNKD-DISK, where disk writes dominate network time), increasing N from 2 to 10 with W = R = 1 lowers immediate visibility at t = 0 from 58% to 21%, because only one of ten replicas has finished writing at commit. Yet the time to reach 99.9% visibility increases by only about 20%.

What the logbooks showWhat the latency logs show

The quick way costs little

Bumping the reader from R = 1 to R = 2 (while keeping W = 1) slashes the wait for 99.9% visibility by 85%, while keeping combined read-and-write latency vastly lower than strict quorums.Bumping the client from R = 1 to R = 2 (while keeping W = 1) slashes the wait for 99.9% visibility by 85%, while keeping combined read-and-write latency vastly lower than strict quorums.

A reader who returnsA client that returns

Never going backwards

A returning reader may not mind a copy slightly behind the newest version, as long as time never runs backwards: the reader is never handed a version older than one read on an earlier visit (monotonic reads).Sometimes a returning client does not mind if a copy is slightly behind the very newest version, as long as it never sees time run backwards, that is, it is never handed a version older than one it already read on an earlier visit (monotonic reads).

Suppose that between two visits by the same reader, an average of m = γgw / γcr new versions are announced on the coast. Any of the newest 1 + m versions (the one read last time, plus the m written since) is at least as new as what the reader saw before, so monotonic reads reduce directly to k-staleness with k = 1 + m.Suppose that between two visits by this client, an average of m = γgw / γcr new versions are committed. Then any of the newest 1 + m versions (the one the client saw last time, plus the m versions written since) is at least as new as what the client saw before! That reduces monotonic reads directly to k-staleness with k = 1 + m.

How likely is a step backwards? three home libraries, the quick wayHow likely is it to read an older version? three replicas, the quick way

Versions announced between two visits, on averageVersions committed between two visits, on average
1versions will doversions will dochance of going backwards

One sure way

Keep to the same home libraryStick to the same replica

A home library replaces a version only when a larger tally arrives, so its copy never moves backwards. A reader who always sends their requests to the same home library (sticky replica) never steps backwards unless that library closes.Because a single replica only ever replaces a version when a larger timestamp arrives, its copy never moves backwards. A client that always directs its requests to the same replica (sticky replica) is guaranteed never to read an older version unless that replica goes down.

Proof · that PBS monotonic reads is k-staleness with k = 1 + γgw / γcr

Let a client read a data item at rate γcr and let the item be written, by all clients, at rate γgw. Claim. The probability of violating monotonic reads is psMR = (C(N − W, R) / C(N, R))1 + γgw / γcr.

  1. This is §3.2. Let a client read a data item at rate γcr and let the item be written, by all clients, at rate γgw. Between two successive reads by this client the expected number of versions committed is γgw / γcr.
  2. A read satisfies monotonic reads if it returns the version the client last read, or any newer one. If the last read returned version vi−k and the latest committed is vi, with γgw / γcr versions in between, the acceptable versions are the newest 1 + γgw / γcr.
  3. That is PBS k-staleness with k = 1 + γgw / γcr, so the probability of violating monotonic reads is psMR = (C(N − W, R) / C(N, R))1 + γgw / γcr, Equation 3.
  4. For strict monotonic reads, where the client must read strictly newer data if any exists, the exponent is γgw / γcr. The paper uses expected values of the rates, which in practice are measured as distributions.∎
The limits

What it does not say

PBS lets a library state the exact odds that a copy is current. Here are four things it cannot say.PBS lets a system state the exact odds that a copy is current. Here are four things it cannot say.

Outside a library's porch: a scholar steps down onto the bare terrace with a freshly copied scroll in his hands, bushes along its edge and the inlet of the sea beyond

Is this particular copy guaranteed to be current?

With partial quorums (R + W ≤ N), the answer is always no. The library can promise nine times in ten you receive the newest version within ten milliseconds, but in the worst case, if couriers are stopped, a partial quorum can return an arbitrarily old copy.With partial quorums (R + W ≤ N), the answer is always no. The system can promise nine times in ten you receive the newest version within ten milliseconds, but in the worst case, if messages are lost or cut off, a partial quorum can return an arbitrarily old copy.

What do the odds assume?

They assume that courier delays are drawn independently from the distributions recorded in the logbooks, with no stopped couriers or closed libraries. They also conservatively ignore background anti-entropy (the festival and word of mouth) and read repair, which make real-world staleness even rarer.They assume that message delays are drawn independently from the distributions recorded in the latency logs, with no lost messages or crashed replicas. They also conservatively ignore background anti-entropy and read repair, which make real-world staleness even rarer.

Can a reader tell at the moment of reading that a copy is stale?Can a client tell at the moment of reading that a copy is stale?

Not when the first R replies arrive. Only afterward, when the remaining N − R replies trickle in, can the reader spot a larger tally that arrived late, and even that can be a harmless false alarm if the late reply reflects a version written after the read began.Not when the first R replies arrive. Only afterward, when the remaining N − R replies trickle in, can the client spot a larger timestamp that arrived late, and even that can be a harmless false alarm if the late reply reflects a version written after the read began.

What of rules across several entries, and causal order?What of multi-item invariants and causal order?

PBS measures how recent one entry is. A reader who needs guarantees across several entries, such as never reading a reply before the entry it answers, or never leaving an entry without a source, needs guarantees about whole visits, and a library alone can give those only in part.*PBS measures recency on a single item. Clients that need guarantees across several items, such as never seeing a reply before the message it answers, or never breaking a constraint that spans two items, need transactional guarantees, which a replica cut off from the rest can give only in part.*

With small quorums a read may be stale, and the chance falls fast with every version of leeway and with every moment since the write was acknowledged.

It is a probability and a way to tune it. The worst case stays unbounded.

Setting Libraries That Agree in the End

The paper behind this book

Peter Bailis, Shivaram Venkataraman, Michael J. Franklin, Joseph M. Hellerstein and Ion Stoica, Probabilistically Bounded Staleness for Practical Partial Quorums. Proceedings of the VLDB Endowment, Vol. 5, No. 8 (38th International Conference on Very Large Data Bases, Istanbul, August 2012), 776–787. — Partial quorums, PBS k-staleness, t-visibility and monotonic reads, the WARS model, and a Monte Carlo evaluation on production latency data.

The ideas, plainly.

Bailis and co-authors study data kept on several machines, where a write is acknowledged after W of N machines have it and a read returns after R machines have answered. If R + W exceeds N, a read always meets the latest write. Operators often choose smaller numbers, for speed, so that a read may miss it. The paper asks how often, and shows that a read within k versions of the latest has probability 1 minus p to the k, where p is the chance of a plain miss: the chance of being stale falls exponentially with the leeway allowed. Monotonic reads is the same idea with k set by how often a reader returns compared with how often the data is written.Bailis and co-authors study data kept on several machines, where a write is acknowledged after W of N machines have it and a read returns after R machines have answered. If R + W exceeds N, a read always meets the latest write. Operators often choose smaller numbers, for speed, so that a read may miss it. The paper asks how often, and shows that a read within k versions of the latest has probability 1 minus p to the k, where p is the chance of a plain miss: the chance of being stale falls exponentially with the leeway allowed. Monotonic reads is the same idea with k set by how often a client returns compared with how often the data is written.

Staleness in time is harder, because writes keep reaching more machines after they are acknowledged. The paper models the four message delays of a write and a read, W, A, R and S, shows that a read is stale when its request reaches a replica before the write does, and works out the odds by simulation using measured delays. The results are that the delay of the write message, and above all its variance, matters most, and that typically the chance of reading the latest write is high within a short time of its commit, at a latency far below that of a strict quorum.

What the paper offers is therefore a probability and a way to tune it, not a guarantee: the worst case stays unbounded, and the odds rest on assumptions about independence and about the delays staying as they were measured.

The paper has five authors: Peter Bailis, Shivaram Venkataraman, Michael J. Franklin, Joseph M. Hellerstein and Ion Stoica, and all are credited here. Nobody in this telling is named; the writer, the home libraries and the reader are told apart by what they do.The paper has five authors: Peter Bailis, Shivaram Venkataraman, Michael J. Franklin, Joseph M. Hellerstein and Ion Stoica, and all are credited here.

In the paper, term by term
an entry's home libraries: the same few libraries hold every copy of itThe replication factor N; one quorum system per data item. §2.1, §2.2.
a version with its tally, the day and hour by the sunA version with a timestamp giving a total order. §2.1.
the writer sends the version to all the home librariesThe coordinator sends the write to all N replicas. §2.2.
announced when enough home libraries have answeredThe write quorum W: the write commits after W acknowledgments. §2.2.
a reader asks all home libraries and takes the first few repliesThe read quorum R: the read returns after R responses. §2.2.
the version still on its way to the other home libraries after it is announcedExpanding quorums: the write quorum grows by anti-entropy after the write returns. §2.2.
groups sharing a home library when the numbers add to more than the home librariesA strict quorum system: R + W > N. §2.1.
the quick way: wait for one, ask oneA partial quorum, R + W ≤ N, as deployed by operators. §1.1, §2.3.
the chance the groups miss each other; excellent for a crowd of home librariesProbabilistic quorums: ps = C(N − W, R) / C(N, R). §2.1.
one of the newest few versions; the chance falls by the same fraction eachPBS k-staleness: psk = psk. §3.1.
a busy home library asked less oftenLower quorum load under staleness tolerance. §3.3.
the odds a while after the announcementPBS t-visibility; the window of inconsistency. §3.4.
one of the newest few, a while afterPBS ⟨k, t⟩-staleness. §3.5.
the four legs: the version out, the acknowledgment back, the request out, the copy backThe WARS model: the delay distributions W, A, R, S. §4.1.
stale when the request outruns the versionA read is stale when the first R responses reached their replicas before the write. §4.1.
the couriers' logbook; replaying it by lotLatency distributions; Monte Carlo simulation, validated against Cassandra. §5.1, §5.2.
the four coastsLNKD-SSD, LNKD-DISK, YMMR and WAN latency fits. §5.4, §5.5.
a reader who never goes backwardsPBS monotonic reads: k = 1 + γgw / γcr. §3.2.
keeping to one home libraryA sticky replica. §3.2.
learning afterwards from the late repliesAsynchronous staleness detection, with false positives. §4.3.
no festival and no word of mouth countedThe conservative assumption: read repair and Merkle-tree exchange never occur. §4.2.
a promise with odds: nine in ten, and nearly always one of the newest fewPBS consistency: an expected bound, not a guarantee; latency/staleness SLAs. §1.2, §6.