CS PAPERS DEEP-READ · PAPER 31

Time, Clocks, and the Ordering of Events

Leslie Lamport · Massachusetts Computer Associates · CACM 1978

中文 →

What did this paper do?

In 1978, Leslie Lamport pinned down an idea that is now everywhere: in a system of independent computers, how do you say "this thing happened before that thing"? Today, when you send a payment or a message, several machines are usually working together behind the scenes; they must agree on "what happened first," or the books won't balance. Lamport gave the first clean answer, and this paper became the intellectual origin of the whole field of distributed systems.

First, an everyday puzzle

You and a friend are in two cities, each looking at your own wristwatch — but the two watches don't quite agree, and they drift further apart over time. Now decide whether "the letter you mailed this morning" happened before or after "something that happened on your friend's end." Just comparing the two watches is hopeless. Networked computers are exactly like this: each has its own quartz clock, all of them drift, and network messages arrive after unpredictable delays. With no single clock everyone trusts, "before and after" becomes a genuine problem.

The idea

Lamport's twist: don't compare clocks — look at who can influence whom. The key handle is messages: a message must always be sent before it can be received. So the moment A sends B a message, you can be sure "A's event came before B received it." Within one machine, whatever ran first is first. Chain these together and you get a web of "who is before whom" (this is the happens-before relation).

The elegant part: some events can't influence each other at all (no message ever passed between them), so we simply call them "simultaneous / concurrent" and refuse to force an order — which is actually more honest.

How does a machine compute the order automatically?

Give each machine a "ticket counter" (not a clock — just a number that keeps growing). The rules fit in three lines: every local event bumps the counter by 1; when you send a message, stamp your current number on the envelope; when you receive one, jump your number above the number on the envelope.

It's like a post office postmark: mailing a letter stamps a number; the receiver sees "ah, this was mailed as #7" and pushes their own counter to #8 and onward. That way whenever one event can influence another, its number is guaranteed to be smaller — the ticket counter sorts "before and after" for you. Smaller number goes first; if two collide, break the tie by machine ID as a referee. So machines scattered across the world can produce one single ordering that everyone agrees on.

What does this buy us?

With that shared ordering, you can make several backup machines process the same batch of commands in the same order — same input, same sequence, so each computes the same result and they stay forever consistent. This recipe for "keeping multiple replicas in lockstep" is the common ancestor of today's bank databases, cloud storage, and famous algorithms like Paxos and Raft. A 1978 counter trick holds up half the distributed-systems world.

One honest caveat: the ticket counter only guarantees "if there's influence, the number is smaller"; the reverse doesn't hold — two events with different numbers need not have any real ordering; they may just happen to collide while being completely unrelated. Untangling that layer needs the heavier "vector clocks" that came later.

Remember one thing

With no clock everyone trusts, stop comparing clocks — define order by "a message is always sent before it's received," give each machine an ever-increasing ticket number so causally related events get smaller numbers, add a tie-breaking referee, and machines a world apart can produce one agreed-upon ordering — staying independent yet always consistent. This is the intellectual origin of distributed consistency.

Want the space-time diagram, the logical-clock update rules, and that no-coordinator mutual-exclusion algorithm? → switch to the deep read