Diffinery

homeflare/celldpublic

celld/docs/simulations.md
93 lines · 5.3 KBRaw History
1# Simulations
2
3Confidence in celld is built up in several ways. This page describes one of
4them: end-to-end simulations on live fleets, where real nodes coordinate
5through a real object store under real workloads, and we observe what actually
6happens when things go wrong.
7
8Simulations are empirical evidence at a scale and realism that reasoning alone
9cannot reach. Running the whole system on many machines, with real storage
10latency and real network partitions, and then breaking it deliberately, shows
11whether celld's guarantees hold in practice and not only by design. This page
12records those runs in broad strokes and grows as we run more of them, across
13larger fleets, denser cell populations, longer partitions, and more varied
14failure modes.
15
16Every result shares the same substrate: a fleet of celld nodes coordinating
17only through one S3-compatible bucket, one SQLite database per Durable Object,
18synchronous durability — a write is replicated to the bucket before its response
19is released, so an acknowledged write is durable (RPO=0) — and a single
20authoritative writer per cell fenced by an epoch in the object-store path. Each scenario attacks that substrate at a
21different seam. Faults are injected between verification passes that fetch cells
22through arbitrary nodes and check their durable state exactly — status, body,
23and full message ledger — so every run has a clean before-and-after. A cell may
24go briefly unavailable while ownership moves, but its committed state must
25survive intact and be served again from a live node.
26
27## What survives
28
29**A hard process crash loses no acknowledged write.** Kill a node's process
30outright — even mid-write-stream — and its resident cells are orphaned instantly.
31Because the output gate holds each write's response until it is durable, every
32acknowledged write is already in the bucket: a surviving node re-acquires each
33cell and serves it from replicated state, at a bounded time-to-availability
34measured as a distribution.
35
36The direct test is deliberately adversarial: issue writes back to back, `SIGKILL`
37the process mid-stream, then *delete the node's local database* so recovery can
38only come from the bucket, and cold-restore the cell. Twenty writes acknowledged
39and killed this way recover all twenty; an eight-cell run of 156 acknowledged
40writes recovers all 156. **Zero acknowledged writes lost, across every run.**
41Before the output gate, the same kill dropped the recently-acknowledged writes
42that had not yet replicated — which is exactly what the gate is there to prevent,
43and exactly what these runs check for on every fault.
44
45**A returning partitioned owner cannot corrupt state.** Freeze a node so it
46still believes it owns its cells, write to those same cells through peers, then
47thaw it. It discovers its lease has moved and refuses to serve stale data
48rather than resurrect it. The peer writes land exactly once, the original state
49is intact, and ledgers stay consistent — at most one writer per epoch, enforced
50through the bucket, even against an owner that comes back to life.
51
52**A node that cannot replicate stops owning.** Cut a node off from the bucket so
53it can no longer prove durability, and it self-fences rather than accept writes
54it cannot replicate. "I can't replicate" is treated as "I must stop owning," not
55as a degraded-but-serving state.
56
57**Losing a whole host is a non-event for the data.** Halt an entire node at the
58provider level, mid-workload, and its cells move to survivors; when the host
59returns it rejoins cleanly with no duplicate residency.
60
61Across these scenarios, no committed cell state has been lost or corrupted, and
62between every fault the verification sweeps return zero body, status, or
63missing-message failures.
64
65## A few numbers we trust
66
67Confidence is also quantitative. These are the simplest measurements an engineer
68tends to ask for first; each carries the condition it was taken under, because a
69number without its conditions is a rumor. Fuller ledgers live in the project's
70spec sheet.
71
72- **A warm resident request is local.** A request to an already-resident Durable
73 Object does zero bucket operations and returns in **p50 ~1.1 ms, p99 ~7 ms**
74 (fixed-host measurement). Only cold activation pays for object storage.
75- **A durable write costs one bucket round-trip.** That round-trip *is* what
76 RPO=0 means — the response is held until the write is in the bucket — so the
77 single-write latency floor is the storage round-trip, not something the engine
78 can optimize away. Concurrent writes to one cell batch onto a shared upload, so
79 per-cell throughput is not one-round-trip-per-write.
80- **Ten small nodes held real scale.** A ten-node fleet of 4-vCPU/8-GB machines
81 carried **10,000 resident cells and 20,000 concurrent WebSockets**, and after
82 halting two of the ten, every cell's data was available again on a survivor
83 within ~11 s at the tail (with reserve headroom).
84
85## The failure edges we intend to find
86
87Confidence also means knowing where a policy stops holding, so those edges are
88recorded rather than tuned away. The clearest one is reserve headroom: a fleet
89packed to its hard resident ceiling has nowhere to place cells displaced by a
90node loss, so simultaneous multi-node failure at the ceiling degrades where a
91fleet with headroom does not. Measuring both sides of that line — healthy
92restoration with reserve, and the red case without — is part of the work, not
93an embarrassment to hide.