If no two machines agree on the time, how can they agree on what happened first? And when two things happen far apart, how can anyone tell whether one led to the other or neither knew of the other?
We find out by exploring how ancient Greek trading houses kept the order of trades when sundials became useless on cloudy days.
After Leslie Lamport, Time, Clocks, and the Ordering of Events in a Distributed System, 1978 · Colin J. Fidge, Timestamps in Message-Passing Systems That Preserve the Partial Ordering, 1988 · Friedemann Mattern, Virtual Time and Global States of Distributed Systems, 1988

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
Computers that work together must often agree on the order in which things happened: which of two writes came first, or whose request is served next.
A clock on the wall would settle it. But every machine has a clock of its own, the clocks disagree, and no message tells how long it took to arrive. Two ideas get an order without a shared clock.
The first gives every machine the same order of events. The second also tells which events could have known of which. We tell it with three trading houses on an island whose sundials have gone dark.
Each machine trusts its own clock. Press the button.
House 1, House 2 and House 3 stand round the coast of Arche with a mountain between them. Word passes between them only on written slips, carried by messengers along the one road.
House 3 has grain in its storehouse, enough for one of the other houses, and both need it. House 2 sends a messenger with a request for it. House 1, knowing nothing of this, sends a messenger with a request of its own.
The houses have agreed that the request placed first is filled first, so House 3 must find out which one that was. The plain way is to see whose messenger reaches the gate first.

House 2 always writes its request first here. Choose whose messenger has the quicker legs.
The gate rewards the house with the quicker messenger, whichever house wrote first. House 3 could instead ask each house the hour its request was written, and it would get two readings of two water-clocks that were never set together. Every way of settling it asks for a clock the island does not have.
The houses need not give up filling the first request first. They have been asking a question that nobody on Arche can answer, and beside it lies a narrower one that every house can.
The narrower question came from House 1's accountant. Which of two requests the sun saw first is something no house can see, and trade needs less than that: a request should never be filled before one that could have led to it.
What could have led to what is something every house can see, because news moves on Arche only by slip. The accountant set it down in three rules. One event came before another in exactly these three cases.
Both happened in one house, and its account scroll has the first written above the second.
The first is a house sending a slip, and the second is another house receiving that same slip.
The first came before some third event, which came before the second.
Here is one morning's business at the three houses. Choose any two entries, and the rules say whether one came before the other.
Each line is one house, at one moment after another. Each dot is an entry in its scroll. Each arc is a slip on the road.
Choose any two dots. Did one come before the other?
If none of the three rules joins two events, they are unrelated. That does not mean they happened at the same moment. It means neither could have known of the other, since no chain of slips joins them. The sun may have seen one before the other, and nothing the houses hold can say which.
Three rules make a definition, and a clerk needs something to calculate with. For that the accountant gave every counting room a number.
The number is the tally. Every counting room keeps one, writes it on every slip it sends, and raises it by two mechanical rules. Scroll slowly, and the picture moves with you.

Ten entries in three scrolls, and three slips on the road. No entry has a number yet.
A house advances its tally by at least one between any two entries in its own scroll. Sending a slip is an entry too.
House 1 writes its current tally, 2, on the slip it sends to House 2.
House 2 stood at 1. The slip says 2. So House 2 sets its tally higher than the slip, to 3, before entering the arrival. A tally is never lowered.
House 3 stood at 2 and receives a slip marked 4, so its entry is 5. House 1 stood at 2 and receives a slip marked 6, so its entry is 7.
Follow the red chain from house to house: 1, 2, 3, 4, 5, 6, 7. Whatever could have led to an entry has a smaller tally than that entry.
Look at the two ringed entries. No chain joins them. House 3's entry lies further out, later by the sun, yet it carries 2 and House 2's carries 3. The tally puts a sequence where nature left none.
So the tally respects every chain of slips, and it says nothing true about two entries that no chain joins. The two requests for House 3's grain are exactly such a pair, and House 3 still has to fill one of them first.
House 3 may know that the two requests are unrelated and still not know whose to fill. The houses need a sequence that decides between every pair, that every house works out alike, and that never contradicts a chain of slips.
House 1's accountant got one by the plainest means there are. The rule of precedence: compare tallies, and where they are equal the lower house number goes first, House 1 before House 2 before House 3. The six entries below reached the three houses in different orders.
Precedence does not find out which of two unrelated requests was really first, and nothing the houses hold could. It replaces the question with an answer every house reads the same way. The answer is fair in the one sense the houses can check: where one request led to another, they are filled in that sequence, and no house wins by owning a quicker messenger.
The houses can now agree on a sequence without a clock. A harder test is something that only one house may use at a time, with no master to hand out the turns.
Write a → b when event a came before event b, and C(a) for the tally of a. The two rules of the tally give the Clock Condition: a → b implies C(a) < C(b). For a at house i and b at house j, precedence a ⇒ b holds if (1) C(a) < C(b), or (2) C(a) = C(b) and i < j. Claim. ⇒ is a total order, and a → b implies a ⇒ b.
The island's common storehouse is such a thing. It is cut into the rock beside the road, and only one house may load from it at a time.
A porter at the door who let in whoever asked first would be fooled as House 3's gate was, because a request can reach the door ahead of one sent earlier over a longer stretch of road. So there is no porter. Each house keeps its own queue of requests, in order of precedence, and follows five rules. Scroll to watch two houses ask at once.
Every house holds a queue of its own. Nobody is asking for the storehouse.
House 1 writes a request under its tally, 2, puts it in its own queue and sends it to both other houses. House 3, knowing nothing of this, does the same under its own tally, also 2.
House 3's request stands first in House 3's queue, and still House 3 may not load. An older request may be on the road right now, in a messenger's pouch.
Each house enters the request it receives. The tallies tie at 2, so House 1's goes first by house number, in all three queues.
A house that receives a request advances its tally and sends an answer. Every answer carries a tally above 2.
House 1's request stands first in its queue, and it has heard from both other houses with tallies above 2. Both halves of the rule hold. House 3 has heard from everyone too, but stands second, and waits.
House 1 removes its request from its own queue and sends a release to both other houses.
Each house strikes House 1's request. House 3 now stands first, and has long since heard from everyone.
To load early, House 3 needed a slip from House 1 with a tally above 2. On a road where no messenger passes another, that slip arrives after House 1's request. So the request was already in House 3's queue, ahead of its own.
The houses now share a storehouse by a sequence they all agree on, with no clock and no master. The sequence is their own, though, and it can part from what the sun saw. One way across Arche shows how far.
Ri is the request of house i, and C(Ri) the tally it was written under. Rule 5: house i enters when Ri stands first in its queue, ordered by ⇒, and it has received from every other house a message carrying a tally greater than C(Ri). Messages from one house to another arrive in the order sent. Claim. No two houses hold the storehouse at the same time.

The way across is over the mountain. A goatherd who knows the smugglers' tracks can cross it in a couple of hours, with luck. The same goatherd may take two days, or never come down, which is why no house sends its business that way.*
News can still travel with a goatherd, who carries no slip. Suppose a trader at House 3 concludes a sale and pays a goatherd to take word of it to House 1, while the official slip goes round by the road.
House 3 has had a busy morning. House 1 has had a quiet one.
By its own rules the tally has done nothing wrong. The rules touch only slips, and the goatherd carried none. As far as the houses' scrolls can tell, the sale and the request are unrelated, though one caused the other as surely as if a messenger had carried the news.
The goatherd is one thing the tally misses. The clerk of House 2 has found another, and this one lies on the road itself.
The clerk of House 2 has a doubt that the tally cannot settle. Two entries carry 4 and 5. One may have led to the other, or each may have been made knowing nothing of the other, and the two numbers read the same either way.
A single number cannot say which, because it mixes together everything a house has heard. When House 2 raises its tally past a slip, it forgets whose number it was raised past. Remembering takes one number for each house. So each house keeps a column of three rows: row by row, the latest count of each house's entries that it has heard of. Three rules keep the column.
On every entry of its own, a sent slip included, a house adds one to its own row.
Every slip is stamped with the sender's full column, as it stands after that entry.
On receiving a slip, a house takes the larger number in each row, then adds one to its own row.
The dots show tallies. Choose two entries to compare their columns. Try the 2 on House 3's line and the 3 on House 2's.
Comparing two columns row by row settles the clerk's doubt. One entry came before another exactly when its column is no greater in every row, and the two columns differ. Two entries are unrelated exactly when neither column is at least the other. Where the tally could only fail to rule out a connection, the column finds it or rules it out.
Only what never went by slip is left unseen, and that brings back the goatherd.
House i keeps a vector Vi with one component for each house. Rule 1: on every event of its own, a send included, it increments Vi[i]. Rule 2: a message carries the sender's vector as it stands after that increment. Rule 3: on receiving a vector U, house j sets Vj[k] to max(Vj[k], U[k]) for every k, then increments Vj[j]. V(a) is the vector at event a; V(a) ≤ V(b) means no component is greater, and < means ≤ and not equal. Claim. a → b if and only if V(a) < V(b); and a ∥ b (unrelated) if and only if neither V(a) ≤ V(b) nor V(b) ≤ V(a).
The column is built from slips and nothing else, so the goatherd escapes it too. Catching the goatherd would take numbers that rise along every path in the world, slip or no slip, and only clocks that run with the world can promise that.
Such clocks can be described. Each house keeps a true clock, every slip carries the sender's reading, and a house that is behind sets itself forward. If the clocks never disagree by more than the goatherd's fastest crossing, the goatherd can no longer arrive before setting out.
Arche cannot keep them. They need a longest journey and messengers at regular hours, and the trading season gives neither. So the houses are left with the tally and the column, and it is worth saying plainly what each one sees.

It gives every house the same sequence. It cannot say whether two entries were joined or unrelated.
It tells joined from unrelated exactly, at the cost of one number for each house.
The sequence the houses keep is their own. A sequence judged by the sun would be a different promise, and a harder one.
Read the island again with machines in the counting rooms. Every house is a process, every slip is a message, and the tally is a counter that each machine keeps. Hover over a row, or tap it, to see who is who.
Without a shared clock, machines can still agree on one order of events that never puts an effect before its cause.
One counter cannot tell related events from unrelated ones. One counter per machine can.
Lamport's logical clocks, and the vector clocks of Fidge and Mattern, are how distributed systems still put events in order.
Setting The Ring Road
The papers behind this book. Leslie Lamport, “Time, Clocks, and the Ordering of Events in a Distributed System,” Communications of the ACM 21, 7 (July 1978), 558–565. Colin J. Fidge, “Timestamps in Message-Passing Systems That Preserve the Partial Ordering,” Proc. 11th Australian Computer Science Conference (1988), 56–66. Friedemann Mattern, “Virtual Time and Global States of Distributed Systems,” Proc. Workshop on Parallel and Distributed Algorithms, North-Holland (1988), 215–226.
Lamport, L. Time, clocks, and the ordering of events in a distributed system. Commun. ACM 21, 7 (1978), 558–565.
Fidge, C. J. Timestamps in message-passing systems that preserve the partial ordering. Aust. Comput. Sci. Commun. 10, 1 (1988), 56–66.
Mattern, F. Virtual time and global states of distributed systems. In Parallel and Distributed Algorithms, M. Cosnard et al., Eds. North-Holland, 1989, pp. 215–226.