← Lessons

quiz vs the machine

Gold1490

Concurrency

Causal Delivery

Use vector clocks to ensure causes are delivered before their effects everywhere.

5 min read · core · beat Gold to climb

Cause before effect

Causal delivery guarantees that if message A could have caused message B, then every receiver delivers A before B. Unrelated messages, called concurrent, may arrive in any order. This captures the intuition behind a reply never appearing before the post it answers.

Tracking causality

Causality is tracked with vector clocks. Each node keeps a counter per node. A message carries the sender vector, recording what the sender had seen when it sent.

  • A receiver holds a message until it has already delivered everything that message depends on.
  • Once dependencies are met, it delivers and advances its own clock.

This buffering is what enforces the order. A message that arrives early waits until its causes catch up.

What it does not give

Causal delivery is weaker than total order. Two concurrent messages with no causal link can be delivered in different orders at different nodes.

  • It rules out causality violations.
  • It allows concurrent events to interleave freely.

Key idea

Causal delivery uses vector clocks to buffer messages until their causes arrive, ensuring causes precede effects while leaving concurrent messages unordered.

Check yourself

Answer to earn rating on the learn ladder.

1. What does causal delivery guarantee?

2. What structure tracks causality for causal delivery?

3. How are concurrent messages handled?