The idea: received is not the same as delivered

A multicast sends one message to every process of a group. The network gives each copy its own delay, so two processes can see the same messages arrive in different orders. An ordered multicast puts a layer between the network and the application. A message is received when the network hands it over, and delivered when the layer passes it up to the application. In between it waits in a hold-back queue until the ordering rule says it may go.

Inside one process: messages from the network are received into a hold-back queue; the ordering rule (FIFO sequence numbers, causal vector timestamps or total order) decides when each one moves on to the delivered list that the application reads. Example: b #2 arrives first and waits in the queue until a #1 has been delivered
Every ordering is the same machine: receive, hold back, deliver when the rule allows.
On the canvasMeaning
three lines P1, P2, P3the processes; time runs left to right (down on a phone), one column per tick
coloured boxa message in flight, coloured by the process that wrote it; grey boxes are ACKs
arrowa message that has arrived, from send to arrival; an orange dot at its end means it was held back
green box on a linea delivery to the application, at the tick it happens
process panelseach process's counters (sequence numbers, vector or Lamport clock), its hold-back queue, what it delivered and, for the bank, its balance
results tableone row per ordering run on the same scenario, with ✓ / ✗ for FIFO, causal and same order

The delays are fixed per scenario, so every run is the same and you can compare the orderings on one schedule. Data messages not in the schedule take 2 ticks, ACKs 1 tick.

FIFO order

FIFO order: if one process multicasts a and then b, every process delivers a before b. Each sender numbers its messages #1, #2, …, and each receiver remembers the next number it expects from each sender. A message with a higher number waits. In Demo 1: no ordering, P3 gets b before a, b reaches P3 at t=3 and a only at t=6, so P3 delivers b, a. In Demo 3: FIFO, P3 holds b back until a arrives, b #2 waits in P3's queue for 3 ticks, and at t=6 P3 delivers a and then b.

FIFO says nothing about two different senders. In Demo 4: FIFO, the reply overtakes the question, P1 asks Q "lunch at 12?", P2 delivers Q and answers R "yes". Each sender sends only one message, so FIFO holds nothing back, and P3 delivers the answer R at t=3 before the question Q at t=7.

Causal order with vector timestamps

Causal order: if sending m′ could have been influenced by m (m happened before m′, in the sense of Lamport's happened-before), every process delivers m before m′. Causal order includes FIFO order. One way to get it uses a vector clock that counts only multicasts:

  • before a multicast, Pj adds 1 to its own entry V[j] and puts the vector in the message;
  • Pi delivers a message from Pj with vector Vm when Vm[j] = V[j] + 1 (it is the next one from Pj) and Vm[k] ≤ V[k] for every other k (Pi has seen everything the sender had seen); then V[j] = V[j] + 1.

In Demo 5: causal, the reply waits for the question, R carries [1,1,0]: P2 had delivered one message from P1 when it replied. P3 is at [0,0,1], so R waits. When Q [1,0,0] arrives at t=7, P3 delivers Q and then R. P3's order is now N, Q, R. But P2's is Q, R, N and P1's is Q, N, R: N and Q are concurrent, and causal order lets each process put them where they arrive.

Total order and the bank account

Total order: every process delivers all messages in the same order. It does not say which order, only that it is the same everywhere. This is what replicas need. In the replicated bank account from van Steen and Tanenbaum, every process holds a copy of a $1000 account. P1 adds $100 and P3 adds 1% interest at the same time. Neither update depends on the other, so FIFO and causal order allow any order (Demo 2: no ordering, the bank replicas end at $1111 and $1110):

ReplicaDelivered orderBalance
P1+100, then +1%1000 + 100 = 1100; 1100 × 1.01 = $1111
P2+1%, then +1001000 × 1.01 = 1010; 1010 + 100 = $1110
P3+1%, then +100$1110

Total order with Lamport timestamps and ACKs

The algorithm in van Steen and Tanenbaum uses Lamport clocks, the same clocks Ricart–Agrawala mutual exclusion uses to order requests:

  1. A sender adds 1 to its clock L and multicasts the message with timestamp (L, id). It also puts the message in its own queue.
  2. A receiver sets L = max(L, Lmsg) + 1, puts the message in its queue sorted by (L, id), and multicasts an ACK to everyone else.
  3. A process delivers the message at the head of its queue once every other process has ACKed it.
Demo 6 in time order. Step 1: P1 multicasts +100 (1,P1) to P3 and P2, and P3 multicasts +1% (1,P3) to P1 and P2; every queue sorts by (L, id), so +100 (1,P1) comes before +1% (1,P3). Step 2: the receivers multicast ACKs: P2 sends ACK +1% and then ACK +100 to P1 and P3, P3 sends ACK +100 to P1 and P2, and P1 sends ACK +1% to P3 and P2. Step 3: once every other process has ACKed the head of its queue, each process delivers +100 and then +1%, and every replica ends at $1111.
Every process sorts the same timestamps and waits for the same ACKs, so all three deliver +100 before +1% and end at $1111.

Every process sorts by the same timestamps, so they all deliver in the same order. Why is it safe to deliver the head? An ACK from Pk carries a timestamp larger than the head's. Any message Pk sends later has a still larger one, and any message Pk sent earlier has already arrived, because the algorithm assumes FIFO channels (in both total-order tabs the page's network keeps each link in order, as TCP does). In Demo 6: total with Lamport timestamps and ACKs, every replica ends at $1111, +100 has (1,P1) and +1% has (1,P3): equal clocks, so the lower id goes first, and all three replicas end at $1111. It costs 4 data messages plus 8 ACKs and ends at t=5.

Total order with a sequencer

A simpler way: one process, the sequencer (P2 here), numbers every message. A sender sends to the sequencer only; the sequencer gives the message the next number #g, delivers it and multicasts it to the rest. Everyone delivers in number order, holding back a message whose number comes too early. In Demo 7: total with a sequencer, every replica ends at $1110, +1% reaches P2 first (1 tick against 2), so it becomes #1 and every replica ends at $1110. That is a different order from Demo 6, and that is fine: total order only promises the same order. The links to the sequencer must be FIFO too, or it could number a sender's b before its a. The cost is one extra hop and a single process that every message must pass. Raft and Kafka's partition leader work this way: the leader orders the log.

FIFO vs causal vs total

Demo 8: FIFO vs causal vs total on one schedule runs the question, reply and news scenario three times and fills the results table:

One schedule, three orderings. P1 multicasts Q, P3 multicasts N, P2 replies R after delivering Q; Q is slow to P3. FIFO: P3 delivers N, R, Q, so the reply comes before the question. Causal: P3 delivers N, Q, R, but P2 delivers Q, R, N, so the processes disagree. Total: every process delivers Q, N, R
FIFO lets the reply overtake the question, causal fixes that but leaves concurrent messages unordered, total gives one order everywhere.
OrderingP1P2P3Guarantee
FIFOQ N RQ R NN R QFIFO ✓, causal ✗, same order ✗
causalQ N RQ R NN Q RFIFO ✓, causal ✓, same order ✗
total (Lamport + ACKs)Q N RQ N RQ N RFIFO ✓, causal ✓, same order ✓ (12 ACKs, done at t=11)

Total order by itself does not promise causal order: a total order could still put a reply before its question. The Lamport version respects it here because a reply is always sent after its question was delivered, so it gets a larger timestamp. A system that needs both asks for causal total order. Replicated state machines, such as MySQL Group Replication, need total order; chat and comment threads usually need only causal order, which is cheaper and needs no ACK round.

What the page leaves out

No message is lost and no process fails, so the page skips the hard part of real group communication: reliable multicast with retransmission, failure detection, and group membership changes (virtual synchrony, as in ISIS). It also skips the ISIS total-order algorithm (receivers propose a priority, the sender picks the maximum), sequencer failover, the equivalence of total-order broadcast and consensus (Paxos, Raft, Zab), and garbage collection of ACK state. The bank interest is rounded to cents.

On the mind map

Open the Distributed Systems mind mapDistributedSystemsReplication: copies of data · what reads seeReplicationPartitioning: split data over nodesPartitioningTime and membership: order events, know who is aliveTime and membershipConsensus: agree on one value or logConsensusTransactions: one change across many servicesTransactionsMessaging: send events between systemsMessagingKafka internals: a replicated append-only logKafka internalsRedis internals: one thread, data in memoryRedis internalsKubernetes: reconcile desired stateKubernetesResilience and speed: stay up and fast under loadResilience and speedLamport and vector clocksLamport and vector clockslogical time; vectors spot concurrencyOrdered multicastTotal order: same delivery order everywhereDistributed mutual exclusionDistributed mutual exclusion3 vs 2(N−1) messages vs one tokenChandy-Lamport snapshotChandy-Lamport snapshotmarkers record a consistent cutGossip and SWIMGossip and SWIMspread in log N rounds; ping-req probesBully vs ring electionBully vs ring electionhighest id wins; ring passes a tokenHybrid logical clocksHybrid logical clockswall time plus counter; TrueTime waitsVector clocks and siblingsVector clocks and siblingsneither vector greater means concurrentOpen the Distributed Systems mind mapDistributed Systemsorder events, know who is aliveTime and membershipLamport and vector clocksLamport and vector clockslogical time; vectors spot concurrencyOrdered multicastTotal order: same delivery order everywhereDistributed mutual exclusionDistributed mutual exclusion3 vs 2(N−1) messages vs one tokenChandy-Lamport snapshotChandy-Lamport snapshotmarkers record a consistent cutGossip and SWIMGossip and SWIMspread in log N rounds; ping-req probesBully vs ring electionBully vs ring electionhighest id wins; ring passes a tokenHybrid logical clocksHybrid logical clockswall time plus counter; TrueTime waitsVector clocks and siblingsVector clocks and siblingsneither vector greater means concurrent
This page on the Distributed Systems mind map · 100 pages in 10 branches · open it to see the whole map and test yourself in recall mode.