Module 2 · Chapter I — Foundations
Champ, the accept tier.
The first tier says yes fast. Champ holds the outbox in a persistent in-heap structure and writes a snapshot to disk every K records, so the accept path runs at heap speed while a single fsync covers a whole interval. This module takes Champ apart in three moves — the structure, the checkpoint dial, and recovery — each by working the figure, not reading a benchmark.
Why an accept tier
graft.design.mdA strict, replicated commit is expensive, and you do not want every enqueue to wait for it. Champ’s job is to absorb the write at heap speed and bound the exposure, leaving the durable, replicated commit to the second tier on its own schedule. The bound is K: the records accepted since the last snapshot are the only ones a crash can take, so K is the loss window in records and the throughput dial at once.
Three properties make that work, and each is a dive. The structure is persistent, so a snapshot is a cheap reference to an immutable version rather than a copy. The checkpoint is periodic, so one fsync serves K records. And recovery is restore-plus-replay, so a lost heap is rebuilt from the last snapshot and the intent log after it — fast, and without the commit tier.
The three dives
module 2The in-heap structure
Why a persistent map: insert a key and watch the new version share every untouched node with the old — structural sharing is what makes a snapshot nearly free.
Dive 2.2The checkpoint dial
K is the loss window. Watch records accumulate against the checkpoint; set K and see the at-risk gauge and the fsync rhythm move together.
Dive 2.3Recovery & replay
A crash, then restore from the last snapshot and replay the intents after it. Step the sequence and see the state come back.
Build & check
A back-of-envelope sizing note for one queue: pick an acceptable loss window in records, set K to it, and state in a sentence what that costs (snapshot frequency) and what it buys (accept latency). No absolute throughput required — just the direction each choice moves.
Explain, without numbers, why a snapshot of a persistent structure does not copy the whole map; and describe what recovery reads, in order, after a crash. If you can narrate restore-then-replay, you have the tier.
References & sources
- Echo records
- graft.design.mdthe accept tier and the checkpoint
- store.design.mdChamp recovery and replay
- External
- Persistent data structuresstructural sharing, the snapshot trick
- Elixir Map & persistent termsthe BEAM's immutable maps
- Designing Data-Intensive Applications, Kleppmann 2017snapshots + logs, recovery (Ch. 3)