Chris Collins

Tools · distributed

Clocks, CRDTs and gossip

Time and agreement without coordination: space-time diagrams with Lamport, vector and hybrid logical clocks (skewed and drifting physical clocks, last-writer-wins gone wrong, causal broadcast); CRDTs from G-Counter to OR-Set and a collaborative RGA text editor across three replicas; and SWIM failure detection and epidemic gossip, animated.

Added

Works with

How to use it

Three things distributed systems do without a coordinator — order events, merge concurrent updates, and agree on who is alive — each as something you can play with in this page. Nothing here talks to a real system.

How to use it

The Clocks and Gossip & SWIM tabs are simulators. Pick a scenario and press Start. Each step does something, plays until it has happened and pauses so you can read what happened and why, with links to the papers. Next step moves on, Back rewinds (the simulator is deterministic, so it replays the earlier steps), ⏭ jumps to the end of the step and Step ⇥ advances to the next single event. Space plays and pauses; → is the next step. Each tab has a playground with no script. Speed scales everything (at 1× a quarter of a simulated second per real second); Hop time is how long a message takes to cross the diagram at 1× — while one is on its way the simulated clock slows down — and Sim clock turns that off. Neither changes what happens. ⛶ Full screen (or f) gives the diagram the whole window with the narration in a side column you can hide; Escape leaves.

Clocks. A space-time diagram: one line per process, true time running to the right, events as dots (grey local, blue send, green receive, orange a write), messages as arrows; a dashed amber stretch is a message held back by causal delivery. Above or below each event is its timestamp — Show picks Lamport, vector, HLC (l.c) or all three. On the left each process’s physical clock offset and drift; on the right its clocks now. Tap an event to see its causal past (amber) and future (pink); tap a second to compare: happened before or concurrent, with the Lamport, vector and HLC timestamps side by side. Tap a process, or use Do something, to add local events, writes, messages and broadcasts, shift a clock, turn causal delivery on, or slow a process’s links. Panels: Events (every timestamp, and each process’s physical clock reading), Last writer wins (which write of a key survives under physical, Lamport and HLC timestamps, and whether a causally later write was lost), HLC vs physical time (the largest l − pt seen against ε, the largest gap between two clocks).

CRDTs. Pick a type. Three replicas, A, B and C, each with its own state; the links between them can be cut. Change any replica (increment, set, add, remove, or type in the text box for RGA), then Sync — one gossip round: every replica merges the state of each replica it can reach — or ⇠ merge one replica into another, or tick auto-sync. Each card shows the value and the full state (tags and tombstones included); the line below says whether the replicas have converged, and the merge laws are checked on the current states. For text, each character’s id (Lamport counter
replica) is shown, and deleted characters stay as struck-out tombstones.

Gossip & SWIM. A group of members around a circle. Each card shows the member’s incarnation number, whom it is probing, and a row of dots: what it believes about every member (green alive, amber suspect, red dead). Messages: ping, ack, ping-req M4 (please ping M4 for me), ack M4 (relay); a +2 means two membership updates ride along. Tap a member to kill, pause (a long GC), isolate or restart it, or cut single links. Panels: every member’s view, and detection times. Below the simulator, a chart runs push, pull and push-pull rumour spreading on n nodes and compares the rounds with theory.

What it models

Limits

  • Clocks: messages are point-to-point or broadcast to everyone; no process groups or membership. Physical clocks are linear (offset plus constant drift) with whole-millisecond readings; there is no clock synchronisation protocol and no NTP step.

  • The LWW comparison stamps each write once with each kind of timestamp; it does not simulate replicas exchanging writes.

  • CRDTs are state-based only (no operation-based delivery), on three replicas, with metadata never garbage-collected (tombstones and tags grow). LWW timestamps are a shared counter with replica B five ticks ahead. RGA edits are diffed as one changed region per keystroke batch.

  • SWIM: no join protocol beyond a restarted member announcing itself, no Lifeguard extensions (no nacks, no local health multiplier, no dynamic suspicion timeouts), no anti-entropy full state sync; the suspicion timeout is a fixed number of periods.

  • The gossip chart uses synchronous rounds and a uniformly random peer each round.

Linking to an example

Links can be written by hand. Add a tab after #: clocks (the default), crdts or swim. A link’s settings replace this page’s saved settings (a button restores yours); a scenario brings its own settings, and parameters given with it override them.

Parameter Meaning Example

example

A scenario from either list below

example=skew-lww

scenario

The clocks scenario, without clearing your settings

scenario=vector

step

Open the clocks scenario at this step

step=3

sscenario

The SWIM scenario (with #swim)

sscenario=swim-failure#swim

sstep

Open the SWIM scenario at this step

sstep=2

procs

Processes, 2–5

procs=4

latency

Message latency, ms

latency=100

jitter

Extra random latency up to this, ms

jitter=0

skew1, skew2, skew3

Physical clock offset of P1, P2, P3 in ms

skew2=-200

drift

Clock drift in ‰: P2 runs this much fast, P3 this much slow

drift=50

causal

Causal delivery of broadcasts (true/false)

causal=true

show

Timestamps drawn: lamport, vector, hlc or all

show=all

members

SWIM members, 3–9

members=9

period

SWIM protocol period, ms

period=300

k

SWIM indirect probes per failed ping

k=1

suspicion

SWIM suspicion (false = basic SWIM)

suspicion=false

suspectMult

Suspicion timeout in protocol periods

suspectMult=8

crdt

The CRDT shown: gcounter, pncounter, lww, mvreg, gset, twopset, orset or rga

crdt=rga#crdts

seed

Random seed (latency jitter, probe order)

seed=7

speed

Playback speed: 0.25, 0.5, 1, 2, 4 or 8

speed=2

hop

Hop time in seconds (0.25, 0.5, 1, 2, anything from 0.1 to 5) or clock

hop=1

Clock scenarios:

example= Shows

lamport

Lamport clocks: the receive rule, the clock condition, and why its converse fails (open)

vector

Vector clocks: element-wise max, happened-before, concurrency detected (open)

skew-lww

A fast clock makes last-writer-wins lose a causally later write; HLC keeps it (open)

hlc

Hybrid logical clocks in detail: the receive rule, the counter, l − pt ≤ ε with drift (open)

causal

Causal broadcast: an answer overtakes its question, then is held until it arrives (open)

clocks-playground

Processes and nothing scripted (open)

SWIM scenarios (add #swim):

example= Shows

swim-probe

The protocol period: pings and acks, round-robin targets, piggybacked gossip (open)

swim-indirect

A broken link: ping-req through k helpers avoids a false alarm (open)

swim-failure

A crash: suspicion, dissemination, confirmation, detection time (open)

swim-refute

A paused member is suspected and refutes with a higher incarnation (open)

swim-playground

A group with no script (open)

Runs entirely in your browser; nothing you type leaves this page.