Diffinery

homeflare/celldpublic

celld/docs/README.md
704 lines · 36.3 KBRaw History
1# celld
2
3celld is a stateful distributed system. It runs server-side JavaScript on
4your machines, and it stores the long-term state in a bucket that you own:
5S3-compatible, Google Cloud Storage, or Azure Blob Storage. The JavaScript
6API and the configuration follow Cloudflare Workers: Workers, Durable
7Objects, KV, Queues, D1, R2, Workflows, Cron Triggers, and static assets.
8
9## Cells and nodes
10
11In Cloudflare terms, a cell is a Durable Object: a small server with a
12name and a private SQLite database. You make one cell for each user,
13document, chat room, or AI agent. A cell serves HTTP, holds WebSocket
14connections, sets alarms, and makes outbound connections. Cells share no
15database. Each cell runs on one thread: a second request interleaves only
16while the first awaits, and storage operations are synchronous.
17
18You run celld as one process on each machine. That process is a **node**,
19and the nodes that share one bucket are a **fleet**. Any node can serve
20any cell, so you add capacity by starting another node against the same
21bucket.
22
23## Cell lifecycle
24
25A cell has the same states as a Durable Object. A **resident** cell is in
26memory: it is **active** while it does work, and **idle** when it waits.
27celld removes an idle cell from memory after `CELLD_IDLE_EVICT_S` seconds
28without work, and earlier under memory pressure or at the residency cap.
29Without `CELLD_IDLE_EVICT_S`, only pressure or the cap removes an idle
30cell. A cell that keeps its hibernatable WebSocket clients on its node is
31**hibernated**. A cell that no node holds is **inactive**: it is only an
32object in the bucket and costs almost zero. Every cell starts inactive.
33
34The constructor runs again on each activation, because a cell keeps no
35memory across these transitions. A hibernated cell wakes like a cold start,
36but its WebSocket clients stay connected and it stays on its node.
37
38Each activation can add a new epoch prefix to the bucket. celld deletes
39the older prefixes only when `CELLD_LTX_RETENTION_SECS` enables epoch GC,
40so without it the bytes of a cell increase with each activation. See
41[epoch GC](guarantees.md#epoch-gc).
42
43One 8 GB node holds 1,000 resident cells, so one resident cell costs
44approximately $0.05 each month.
45
46## Ownership and durability
47
48Exactly one node serves a cell at a time. A node claims a cell with a
49conditional write of a small record to the bucket, so the bucket decides
50who wins. There is no leader election and no membership list. The claim
51expires unless the node renews it, so a failed machine releases its cells.
52
53celld does not answer a write until the data survives a failure (RPO=0).
54`CELLD_DURABILITY` selects how celld proves that a write is durable:
55
56- `bucket`: the node answers after the write reaches the bucket. Each write
57 costs one object store round trip.
58- `fleet` (the default): the node sends each write to one or two other
59 nodes, and it answers when they hold it on disk or when the bucket upload
60 finishes, whichever comes first.
61
62A single node has no peer, so a one-node fleet in `fleet` mode waits for the
63bucket on every write, as `bucket` mode does. Two or more
64nodes are faster, because a follower fsync is much faster than an object
65store write. Run two or more nodes if write latency
66matters. A fleet that loses all but one node falls back to the bucket in the
67same way, and it stays correct. Set `bucket` to wait for the bucket on every
68write, even when peers are available.
69
70When a node stops, another node takes its cells over, and first collects
71the data that the stopped node had not uploaded. See
72[what celld guarantees](guarantees.md) for the mechanism and the bucket
73requirements.
74
75## Alarms
76
77When an event sets an alarm before its response boundary, celld does not
78send a successful response until a durable wake entry covers the alarm. A
79later `waitUntil` alarm does not delay the response of another event.
80
81A hibernated cell fires its alarm on the node that owns it. One node holds
82the waker role, and it wakes only the cells whose owner node has stopped.
83
84## What do you build with cells
85
86- **Real-time applications.** A multiplayer game, a chat room, or a
87 collaborative document is one cell. The room needs no lock and no
88 external message bus.
89- **Agents.** Each AI agent is one cell with its memory, schedule, and
90 inbox in its own SQLite database. An inactive agent costs almost nothing.
91- **Sharded web applications.** One cell for each user, tenant, or device
92 shards the application from the start, so no shared database exists.
93
94## Contents
95
96- [Cells and nodes](#cells-and-nodes)
97- [Cell lifecycle](#cell-lifecycle)
98- [Ownership and durability](#ownership-and-durability)
99- [Alarms](#alarms)
100- [What do you build with cells](#what-do-you-build-with-cells)
101- [Install](#install)
102- [Configure object storage](#configure-object-storage)
103- [Deploy an application](#deploy-an-application)
104- [Develop an application locally](#develop-an-application-locally)
105- [Operate D1, KV, and R2](#operate-d1-kv-and-r2)
106- [Start a node](#start-a-node)
107- [Add nodes](#add-nodes)
108- [Feed an autoscaler](#feed-an-autoscaler)
109- [Shut down and roll out a node](#shut-down-and-roll-out-a-node)
110- [Upgrade notes](#upgrade-notes)
111- [Diagnose a fleet](#diagnose-a-fleet)
112- [List Durable Objects](#list-durable-objects)
113- [Hot-cell overload](#hot-cell-overload)
114- [Environment variables](#environment-variables)
115- [Services](#services)
116- [Cloudflare compatibility](cloudflare-compat.md)
117- [What celld guarantees](guarantees.md)
118- [Limitations](limitations.md)
119- [Security](security.md)
120- [Telemetry](telemetry.md)
121- [Testing](testing.md)
122- [WebAssembly](wasm.md)
123- [Python Workers](services/workers.md#python-workers)
124
125## Services
126
127Each service page contains a runnable example and the known differences from
128the Cloudflare service.
129
130- [Workers](services/workers.md)
131- [Durable Objects / Cells](services/durable-objects.md)
132- [Durable Object Facets](services/durable-object-facets.md)
133- [KV](services/kv.md)
134- [Queues](services/queues.md)
135- [D1](services/d1.md)
136- [R2](services/r2.md)
137- [Workflows](services/workflows.md)
138- [Cron Triggers](services/cron-triggers.md)
139- [Static assets](services/static-assets.md)
140- [Dynamic Workers](services/dynamic-workers.md)
141- [Containers](services/containers.md)
142
143## Install
144
145```sh
146curl -fsSL https://celld.dev/install.sh | sh
147```
148
149The installer downloads the `celld` binary. Replication runs inside the
150process, so a node needs no external replicator. If the installer tells
151you, add `~/.local/bin` to `PATH`. To install one exact release, set
152`CELLD_VERSION` to its tag, for example `v0.0.1`; to go back, run the
153installer again with the previous tag. Each
154[release](https://github.com/denoland/celld/releases) has a build
155attestation: verify a file with
156`gh attestation verify <asset> --repo denoland/celld`.
157
158## Configure object storage
159
160The `s3://`, `gs://`, and `az://` scheme names are case-insensitive, and
161celld ignores leading and trailing whitespace in `CELLD_BUCKET`.
162
163For an S3-compatible bucket, celld uses the standard AWS credential chain,
164including an EC2 instance role and Amazon EKS Pod Identity. For Cloudflare
165R2, create a bucket and an S3 API token with access to it, and set:
166
167```sh
168export AWS_ACCESS_KEY_ID=...
169export AWS_SECRET_ACCESS_KEY=...
170export AWS_REGION=auto
171export S3_ENDPOINT=https://ACCOUNT_ID.r2.cloudflarestorage.com
172export CELLD_BUCKET=s3://YOUR-BUCKET
173```
174
175For Google Cloud Storage, celld uses Application Default Credentials. Run
176`gcloud auth application-default login`, or point
177`GOOGLE_APPLICATION_CREDENTIALS` at a service-account key. Then set
178`CELLD_BUCKET=gs://YOUR-BUCKET`. On Compute Engine, the default instance
179scope permits only storage reads, so create the instance with the
180`cloud-platform` scope.
181
182For Azure Blob Storage, the bucket name is the container:
183
184```sh
185export AZURE_STORAGE_ACCOUNT_NAME=YOUR-ACCOUNT
186export AZURE_STORAGE_ACCOUNT_KEY=...
187export CELLD_BUCKET=az://YOUR-CONTAINER
188```
189
190You must configure exactly one Azure credential family: an account key, a
191managed identity, or a workload identity. A system-assigned managed
192identity needs only the account name. A user-assigned managed identity
193needs exactly one of `AZURE_CLIENT_ID`, `AZURE_OBJECT_ID`, and
194`AZURE_MSI_RESOURCE_ID`. An identity needs the
195[`Storage Blob Data Contributor`](https://learn.microsoft.com/azure/role-based-access-control/built-in-roles#storage-blob-data-contributor)
196role or equal permissions. A managed identity works on an Azure VM and an
197AKS node, but not on App Service or Container Apps; use a workload
198identity or an account key there. The AKS workload identity environment
199(`AZURE_AUTHORITY_HOST`, `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`,
200`AZURE_FEDERATED_TOKEN_FILE`) must use the public authority host,
201`https://login.microsoftonline.com`. celld rejects every other recognized
202Azure configuration variable, such as another credential source or an
203endpoint override. For local development against Azurite, set
204`AZURE_STORAGE_USE_EMULATOR=true`. celld does not qualify Azurite for a
205fleet.
206
207A `gs://` or `az://` bucket takes no `S3_ENDPOINT` and no `AWS_*`
208credentials, and celld ignores the storage region.
209
210The bucket credentials give full control of the fleet, so keep them safe.
211
212A bucket value can add a key prefix, `s3://YOUR-BUCKET/PREFIX`, so two
213fleets can share one bucket. Without a prefix, the objects stay at the
214bucket root.
215
216The store must provide conditional writes, exact ranged reads, and
217read-after-write consistency. Amazon S3, Cloudflare R2, Google Cloud
218Storage, Tigris, and Azure Blob Storage qualify; Backblaze B2, Hetzner,
219and DigitalOcean Spaces do not. MinIO (community edition) passes the
220storage test but is not qualified for production; do not use
221RELEASE.2025-09-06T17-38-46Z, which rejects the first deploy
222(denoland/celld#162). See [what celld guarantees](guarantees.md).
223
224## Deploy an application
225
226Install `esbuild` on `PATH` if the project contains Worker code. Then run
227`celld deploy` in a Wrangler project:
228
229```sh
230git clone https://github.com/denoland/celld
231cd celld/examples/counter
232celld deploy . \
233 --bucket "$CELLD_BUCKET" \
234 --endpoint "$S3_ENDPOINT" \
235 --region "$AWS_REGION"
236```
237
238`celld deploy` accepts module Workers, Durable Object bindings, service
239bindings, variables, cron triggers, D1 databases, KV namespaces, Queues,
240R2 buckets, Workflows, WebAssembly modules, and static assets. An unknown
241Wrangler configuration key stops the deploy. See
242[Cloudflare compatibility](cloudflare-compat.md) for the complete boundary.
243A node verifies the SHA-256 digest of each module before it builds a
244deployment.
245
246A running node does not restart for a new deployment. Each node reads
247`deploy/current.json` every `CELLD_DEPLOY_POLL_S` seconds (default 30) and
248adopts a new deployment in place. `POST /reload` on the internal listener
249adopts it now, and also rebuilds an unchanged deployment. A request that
250started on the previous deployment finishes on it. A deployment that does
251not build leaves the current one serving, and the node reports the error
252in its log and in the `/reload` response.
253
254An inactive Durable Object runs the new deployment at its next activation.
255A resident one moves when no request, alarm handler, or regular WebSocket
256is active, and it keeps its storage and its hibernatable WebSockets. A
257request that arrives during the move waits for the new code. An outbound
258call from a request that already runs in the object does not wait, so that
259request can finish on the old code. After
260`CELLD_DEPLOY_MAX_AGE_S` seconds (default 60; 0 forces at once), celld
261forces the move: it cancels the running work and closes regular WebSockets
262with code 1012, as Cloudflare does. During the move, a request on one
263deployment can call a Durable Object on the other, so two adjacent
264versions must accept each other's calls. `/state` reports the deployment
265of each resident object.
266
267## Develop an application locally
268
269```sh
270celld dev [PROJECT_DIR_OR_CONFIG]
271```
272
273The command starts a local object store, deploys the application, and runs
274one node. It does not need Docker or a cloud bucket. The Worker listener
275is `http://127.0.0.1:9876` by default.
276
277| flag | effect |
278| --- | --- |
279| `--port PORT` | The Worker listener port |
280| `--host ADDR` | The Worker listener interface. The operator listener stays on loopback |
281| `--logs` | Show the node warning and information logs |
282| `--clean` | Delete `.celld/dev` before the start |
283| `--watch-ignore GLOB` | Ignore one more project-relative glob. Repeatable. Not valid with `--no-watch` |
284| `--no-watch` | Disable automatic builds and restarts |
285
286Set `NO_COLOR` to disable color, or `FORCE_COLOR` to enable it when the
287output is not a terminal. `NO_COLOR` takes priority.
288
289The command reads `.dev.vars` beside the Wrangler configuration, as
290`wrangler dev` does. Without `.dev.vars`, it reads `.env` and then
291`.env.local`, which overrides `.env`. Each `NAME=value` entry becomes a
292Worker variable and overrides `vars`. A line can start with `export`, and
293a quoted value can span lines, for example a PEM key. Comments after a
294value and variable references are not supported. In `.env` files, the
295command skips, with a warning, an entry that is not a valid binding name
296or that collides with another binding; in `.dev.vars` such an entry stops
297the build. `celld deploy` does not read these files. Add `.dev.vars`,
298`.env`, `.env.local`, and `.celld/` to `.gitignore`.
299
300The command keeps the local state in `.celld/dev`, across restarts and
301configuration changes. celld does not migrate stored state, so a stored
302value from an earlier configuration can make the application fail with an
303error that looks unrelated. Use `--clean` to start from an empty state.
304`--clean` deletes nothing else under `.celld`.
305
306The command watches the project directory and rebuilds on a source,
307configuration, or dotenv change. The current application serves during the
308build, and a failed build does not replace it. The watcher ignores
309`.celld`, `.git`, `.wrangler`, `node_modules`, and `target` at each depth,
310and it does not watch files outside the project.
311
312The local object store is not available to a fleet node or an operator
313subcommand; they need a supported cloud bucket.
314
315## Operate D1, KV, and R2
316
317These commands use the fleet bucket. `celld d1` and `celld kv` reach the
318database cell through a node.
319
320```sh
321celld d1 migrations apply ledger --bucket "$CELLD_BUCKET"
322celld kv bulk put sessions wrangler-export.json --bucket "$CELLD_BUCKET"
323```
324
325The `migrations_dir` value must be a relative path inside the project,
326without a `..` component. The KV bulk commands use the Wrangler file
327format. `celld kv bulk get` streams; a named output file changes only
328after the export completes, and a failed stdout export leaves an
329incomplete JSON array.
330
331`celld r2` reads and writes the objects of an `r2_buckets` binding under
332the reserved `r2/<bucket_name>/` prefix. It needs no running node, so a
333release pipeline can publish an artifact before it deploys.
334
335```sh
336celld r2 put assets app.zip --path dist/app.zip \
337 --content-type application/zip \
338 --metadata '{"release":"1.2.3"}' \
339 --bucket "$CELLD_BUCKET"
340```
341
342The first argument is the `bucket_name`, not the binding name. `--metadata`
343becomes `customMetadata`, and the content flags become `httpMetadata`. An
344object that another tool writes into the prefix is also readable, without
345`cacheExpiry` or checksums. `celld r2 get` streams the body to stdout, and
346`celld r2 head` prints the stored record; with `--json`, the
347`http` and `custom` fields hold `httpMetadata` and `customMetadata`.
348
349`celld kv list` and `celld r2 list` print at most 1000 keys and print the
350`--after KEY` that continues the listing on stderr. Pass `--all` for every
351key and `--json` for one JSON object per key.
352
353Every celld command writes data to stdout and messages to stderr. A closed
354stdout pipe is a successful stop.
355
356## Start a node
357
358For local development, the default listener is sufficient:
359
360```sh
361celld \
362 --bucket "$CELLD_BUCKET" \
363 --endpoint "$S3_ENDPOINT" \
364 --region "$AWS_REGION"
365```
366
367For a fleet node, bind the public and internal listeners separately:
368
369```sh
370celld \
371 --bucket "$CELLD_BUCKET" \
372 --endpoint "$S3_ENDPOINT" \
373 --region "$AWS_REGION" \
374 --listen 0.0.0.0:8080 \
375 --internal-listen 10.0.0.12:8081 \
376 --advertise node-a.internal:8081
377```
378
379`--advertise` requires an explicit `--internal-listen`, and so does a
380non-loopback `--listen`. You must route the advertised address to the
381internal listener, not to the public listener; celld cannot verify this.
382
383## Add nodes
384
385Start each node with the same bucket settings and its own reachable
386`--advertise` address. The nodes find each other through leases in the
387bucket; there is no join command.
388
389Peer traffic has no TLS and cell fetch and RPC traffic is not signed, and
390the internal listener has an unauthenticated operator API. Put the
391advertised addresses on a trusted private network or an encrypted overlay
392such as WireGuard or Tailscale, and never expose the internal listener to
393the internet. See [security](security.md).
394
395The node that receives a request activates a new cell, so a load balancer
396must include a new node in its rotation. A node at its residency cap or
397under memory pressure hands the activation to the least-loaded peer. A
398pressure eviction releases the ownership record
399(`CELLD_PRESSURE_OWNERSHIP=release`, the default), so the cell can move.
400An idle eviction keeps the record, so the cell wakes on its own node. An
401idle eviction must stop the runtime within `CELLD_OPERATION_DEADLINE_MS`,
402or the cell stays resident until the next idle period.
403
404A new node also receives idle cells. Every node reads a shared fleet
405sample, `fleet/capacity-v1.json`, every `CELLD_REBALANCE_INTERVAL_MS`
406(default 5000; `0` disables balancing). Each node gets a share of the
407owned cells in proportion to `CELLD_PLACEMENT_WEIGHT` (default: the CPU
408count). The most loaded node hands at most 32 idle cells at a time to the
409node furthest below its target, and a receiver fills to 2% below its
410target. Only a hibernated cell moves; its hibernatable WebSockets close
411with code 1012 so that the clients reconnect. A fleet without
412`CELLD_IDLE_EVICT_S` therefore balances only the cells that hibernate on
413their own. A draining node and a node with a cold-activation backlog
414(`restoring`) receive no cells. Nothing moves while a node reports a lease
415without a weight, so a rolling upgrade to this version completes first.
416`POST /rebalance/pause` on any node pauses balancing for the fleet, and
417`POST /rebalance/resume` on the same node resumes it.
418
419## Feed an autoscaler
420
421celld does not scale itself. An external system starts and stops the
422nodes, and celld hands the cells off.
423
424Each node writes its lease to `nodes/<node>.json` in the bucket. The lease
425lives `CELLD_TTL_MS` (default 10000) and renews at one third of that. Its
426load block, dated by `sampled_ms`, contains `owned_cells`,
427`placement_weight`, `resident_cells`, `host_websockets`, `rss_bytes`,
428`in_use_bytes`, `cpu_percent_x100`, `open_fds`, `pressured`,
429`memory_headroom`, `shed_cells`, and `restoring`. `owned_cells` includes
430dormant cells; a restarted node omits it until it has read its ownership
431records. `resident_cells` counts only cells in memory. The memory and CPU
432values are sampled every second.
433
434`GET /state` on the internal listener reports the live counters. Its
435`node_load` object is the lease load block.
436
437| field | meaning |
438| --- | --- |
439| `capacity_waiting` | Activations queued behind the residency cap. Positive means add a node |
440| `activation_waiting`, `restoring` | Cold activations that wait for or hold a permit |
441| `owned_cells`, `occupied`, `shedding` | Ownership, residency, and pressure shedding |
442| `handed_off`, `rebalanced`, `rebalance_failed` | Cells given to peers, the part balancing moved, and the balancing moves no peer took |
443| `remote_route_refreshes` | Cached routes that expired and started a new lookup. Normal lease renewal increases it |
444| `allocator` | Rust allocator bytes: `allocated_bytes`, `resident_bytes`, `mapped_bytes`, `retained_bytes`. V8 heaps are not included |
445| `libc_malloc` | Linux only: `in_use_bytes` and `free_bytes` of the C allocator that SQLite and V8 use |
446| `deployment.isolates`, `deployment.draining` | Per Worker script (`cells`, `stateless`, `services`): `live`, `live_empty`, `retiring`, `freed`, `heap_bytes`, `external_bytes` |
447
448A `live_empty` count that persists for more than 30 seconds means that
449isolate maintenance does not run. A persistent `retiring` count means that
450a turn or a request still holds the heap.
451
452A positive `capacity_waiting` or a `pressured` lease is the signal to add
453a node. Scale down only when every remaining node reports
454`memory_headroom` and a small `restoring` backlog. A drain into a full
455fleet leaves the cells dormant on the survivors, and each later activation
456must shed a resident cell.
457
458`/.well-known/celld/health` on the public listener is a boolean. It
459reports 503 during a drain and before a joining node settles.
460
461## Shut down and roll out a node
462
463celld shuts down gracefully on SIGTERM or SIGINT. The health path reports
464503, new public requests receive 503 with the connection closed, and
465accepted requests finish. The node hands its cells off in batches: it
466cancels running alarms (the successor retries them), proves the data
467durable, publishes a final snapshot, and releases each ownership record to
468a peer. The peer keeps the cell dormant until a request arrives. A
469database larger than the durability deadline can upload (80 MiB at the
470default 10 seconds) hands off without the snapshot. Busy cells move first.
471`POST /shutdown` on the internal listener starts the same handoff.
472
473| variable | default | effect |
474| --- | --- | --- |
475| `CELLD_SHUTDOWN_TOTAL_MS` | 40000 | The complete stop bound. The drain-token wait is 3/4 of it (30000) and the handoff no-progress interval is 5/8 (25000) |
476| `CELLD_RELEASES` | 128 | Concurrent complete handoffs |
477| `CELLD_ACTIVATIONS` | see [table](#environment-variables) | Demand-driven restores and startup work |
478| `CELLD_READY_FLEET_GATE_MS` | 120000 | The first-readiness gate deadline; `0` disables the gate |
479
480You must set the orchestrator stop grace (systemd `TimeoutStopSec`,
481Kubernetes `terminationGracePeriodSeconds`) above
482`CELLD_SHUTDOWN_TOTAL_MS`, or SIGKILL can interrupt the handoff. celld
483rejects the removed `CELLD_SHUTDOWN_DRAIN_MS` and
484`CELLD_DRAIN_TOKEN_WAIT_MS` at startup.
485
486Concurrent stops do not flood the survivors: a draining node claims a
487fleet drain token, so nodes hand off one at a time. A node that cannot
488claim the token within its wait proceeds without it.
489
490A new process does not report healthy until the fleet settles: no node
491drains, every node is below its memory low watermark, the restore backlogs
492are small, and ownership is balanced. At `CELLD_READY_FLEET_GATE_MS`,
493celld logs `ready_gate_expired` once, but readiness stays closed, so set
494an orchestrator rollout deadline. After the first healthy response, fleet
495state does not remove readiness.
496
497A cut handoff can leave the log of the stopped process for its
498replacement to recover. Another process can replace a recovery that does
499not respond for 30 seconds.
500
501A remote call to a cell that is changing owner waits for the new owner,
502for at most `CELLD_OPERATION_DEADLINE_MS` (default 15000). celld retries
503only an attempt that provably did not start. An application must keep one
504stable operation ID when it retries an ambiguous fetch, RPC, D1, or
505service operation. A WebSocket client must reconnect.
506
507To roll out a new version, use the rolling update of your orchestrator:
508stop each node with SIGTERM, wait for its replacement to report healthy,
509and then move to the next node. celld paces the handoffs and readiness
510itself.
511
512`POST /shutdown?handoff=preserve` prepares a same-node restart that keeps
513the ownership records. It cancels cold activations and uploads each
514stopped database first. If an upload fails, the next process uses normal
515recovery. The internal operator API is alpha and can change in any
516release, so keep operator tooling and celld releases together.
517
518## Upgrade notes
519
520- **v0.1.0 to v0.2.0: stop all.** Stop every v0.1.0 node, then start
521 v0.2.0. The two versions use different peer addresses and data formats,
522 so a fleet must not mix them.
523- **v0.2.1 to v0.3.0: rolling.** The default durability changes from
524 `bucket` to `fleet`. Do not start a v0.2.x binary after a node runs
525 v0.3.0 unless its shutdown log contains
526 `node-log close: sealed epoch`. Otherwise, the downgrade can lose
527 acknowledged writes.
528- **v0.3.0 to v0.4.0: stop all.** The peer protocol changes, and a v0.3.0
529 node cannot read new large KV values, so a mixed fleet can make
530 committed KV values unavailable.
531- **v0.4.0 to v0.4.1: rolling.** Paged restore starts one lease lifetime
532 after the last v0.4.0 node stops. Do not start a v0.4.0 binary after
533 that: it cannot restore a paged cell.
534- **v0.5.1 to v0.6.0: stop all with `fleet` durability.** A v0.6.0 node
535 refuses to start against a v0.5.1 follower. A `bucket` durability fleet
536 can roll.
537- **v0.6.0 to v0.6.1: rolling.** Until every node runs v0.6.1, do not set
538 `CELLD_LTX_RETENTION_SECS`, do not deploy a Python Worker, and do not
539 raise `CELLD_MAX_ASSET_FILE_BYTES` above 25 MiB. A rollback to v0.6.0
540 can roll after you unset `CELLD_LTX_RETENTION_SECS` on every node.
541- **v0.6.1 to v0.6.2: rolling.** Until every node runs v0.6.2, a handler
542 failure on the owner of a forwarded Durable Object fetch can reach the
543 caller as a 500 response. A v0.6.2 pair rejects the caller's `stub.fetch()`
544 instead, as a local owner does. A rollback to v0.6.1 can also roll.
545- **v0.6.2 to v0.6.3: rolling.** A v0.6.3 node no longer trusts the
546 emSign ECC Root CA - G3 certificate or the eight compromised eMudhra
547 intermediate CA certificates for outbound TLS, so upgrade each node
548 promptly. Until every node runs v0.6.3, a v0.6.2 node can still acquire a
549 cell whose ownership record was lost and start the cell with an empty
550 database. A rollback to v0.6.2 can also roll.
551
552## Diagnose a fleet
553
554`celld diagnose` reads the node leases and probes each live peer. It does
555not take a lease or change ownership. Use `--peer NODE_ID`, repeatable, to
556probe only some nodes.
557
558```sh
559celld diagnose \
560 --bucket "$CELLD_BUCKET" \
561 --endpoint "$S3_ENDPOINT" \
562 --region "$AWS_REGION"
563```
564
565The report shows expired leases, bad advertised addresses, unreachable
566peers, authentication failures, and protocol mismatches. Each node line
567shows `restoring`, the cold activations in progress. During a rolling
568update, wait for `restoring=0` on every node before you restart the next.
569
570## List Durable Objects
571
572```sh
573celld cell list \
574 --bucket "$CELLD_BUCKET" \
575 --endpoint "$S3_ENDPOINT" \
576 --region "$AWS_REGION"
577```
578
579Each line is a `Class:ID` scope. Give a class name to list only that
580class, and pass `--json` for one JSON object per line. An instance appears
581after its first event; an ID that is only derived does not appear. D1
582databases, KV namespaces, and Workflows are cells in reserved classes whose
583names start with `__`. The `--json` output marks them `"reserved": true`:
584
585```sh
586celld cell list --all --json --bucket "$CELLD_BUCKET" |
587 jq -r 'select(.reserved | not) | .scope'
588```
589
590The command stops at 1000 instances and prints the continuation on stderr:
591
592```
5931000 cells shown; more exist. Continue with --after Room:d99d9174b25e46310694dd931b47fbde70a7460bb7b210b546060651ea2ff6e0
594```
595
596Pass that `--after SCOPE` for the next page, `--limit N` for a different
597page size, or `--all` for everything (one request per 1000, with progress
598on stderr). The listing is not a snapshot, but a sequence of `--after`
599commands lists each existing instance once.
600
601`celld cell gc --dry-run` takes the same options and prints, for each cell,
602the epoch prefixes that epoch GC can delete, their bytes, and the restore
603base. It writes nothing, and it exits with an error at the end if it could
604not read a cell.
605
606```sh
607celld cell gc --dry-run --bucket "$CELLD_BUCKET" --grace-secs 3600
608```
609
610The real deletion can come later or not at all. Only a node with a
611positive `CELLD_LTX_RETENTION_SECS` deletes, with that grace instead of
612`--grace-secs`. A cell deletes only while it is active, after its
613activation has a write and, if paged, after its local file is complete.
614With `CELLD_LTX_COMPACTION=0`, a cell on a fleet node waits for a handoff
615snapshot. One pass deletes at most 64 epochs of a cell.
616
617## Hot-cell overload
618
619celld admits at most 64 concurrent fetch events for one Durable Object
620(`CELLD_MAX_CELL_REQUESTS`). A Queue broker admits 256 concurrent producer
621calls, commits at most 64 in one transaction, and overlaps up to four
622transactions.
623
624Over the limit, celld returns `503` with `Retry-After: 1` and
625`X-Celld-Overload: cell`, and does not start the event. The Queue response
626body is `{"error":"cell admission refused"}`, and a caught Queue producer
627error contains `cell overload: admission refused`. A load generator must
628count these responses as rejected work. celld logs `cell_overload_refused`
629with the cell scope, node, region, in-flight count, and limit.
630
631## Environment variables
632
633For the full list, including advanced tuning switches, run `celld -h`. An
634unset variable selects its default. A Boolean variable accepts only `0` or
635`1`. celld exits at startup on an invalid value.
636
637| variable | purpose |
638| --- | --- |
639| `CELLD_BUCKET` | The fleet bucket, and an optional key prefix. The same as `--bucket` |
640| `S3_ENDPOINT` | The S3-compatible endpoint. The same as `--endpoint` |
641| `AWS_REGION`, `AWS_DEFAULT_REGION` | The storage region |
642| `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_SESSION_TOKEN` | Explicit AWS credentials. The standard AWS credential chain is also available |
643| `GOOGLE_APPLICATION_CREDENTIALS`, `GOOGLE_SERVICE_ACCOUNT_KEY` | Google credentials for a `gs://` bucket. Application Default Credentials are also available |
644| `AZURE_STORAGE_ACCOUNT_NAME` | The storage account for an `az://` bucket |
645| `AZURE_STORAGE_ACCOUNT_KEY` | The storage account key. Do not combine it with an identity selector |
646| `AZURE_AUTHORITY_HOST`, `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_FEDERATED_TOKEN_FILE` | The AKS workload identity environment. The authority must be the public Azure host |
647| `AZURE_STORAGE_USE_EMULATOR` | Set to `true` to develop against Azurite |
648| `CELLD_ADDR` | The public Worker listener. The same as `--listen` |
649| `CELLD_INTERNAL_ADDR` | The peer and operator listener. The same as `--internal-listen` |
650| `CELLD_ADVERTISE` | The internal address that peers can reach. The same as `--advertise` |
651| `CELLD_UNSAFE_PUBLIC_ADVERTISE` | Set to `1` to permit a literal public IP in `CELLD_ADVERTISE`. It does not resolve a DNS name or restrict the internal listener |
652| `CELLD_NODE` | An explicit node-session ID: 1 to 128 ASCII letters, numbers, dots, dashes, or underscores, but not `.` or `..` |
653| `CELLD_WATCH` | The local work directory for SQLite and replication |
654| `CELLD_ESBUILD` | The path of the esbuild executable |
655| `CELLD_ACTIVATIONS` | Concurrent cold-cell activations (default: 8 per CPU, at least 16, at most 128) |
656| `CELLD_DEPLOY_POLL_S` | The deployment pointer poll interval in seconds (default: 30) |
657| `CELLD_DEPLOY_MAX_AGE_S` | Seconds before celld forces a resident Durable Object onto a new deployment (default: 60; 0 forces at once) |
658| `CELLD_OPERATION_DEADLINE_MS` | The deadline for a non-restore operation (default: 15000) |
659| `CELLD_MAX_CELL_REQUESTS` | Concurrent fetch events for one Durable Object (default: 64) |
660| `CELLD_MAX_REQUEST_BODY_BYTES` | The body limit for a public Worker request or a direct Durable Object request (default: 1 GiB) |
661| `CELLD_MAX_RESIDENT_CELLS` | The hard limit for resident cells, enforced at admission |
662| `CELLD_IDLE_EVICT_S` | Seconds after which an idle cell leaves memory and hibernates (unset: only pressure or the residency cap removes an idle cell) |
663| `CELLD_PLACEMENT_WEIGHT` | The ownership share of this node, relative to the other nodes (default: the CPU count) |
664| `CELLD_REBALANCE_INTERVAL_MS` | The fleet sample interval and maximum age (default: 5000; 0 disables balancing) |
665| `CELLD_MAX_RSS_MB` | The memory threshold for pressure shedding, on the greater of the allocator-adjusted RSS and the active cgroup working set (default: 80% of the available memory; 0 disables the threshold and the absolute cap) |
666| `CELLD_DURABILITY` | `fleet` (default): the node sends each write to one or two other nodes and answers when they hold it on disk or the bucket upload finishes. A single node has no peer, so every write waits for the bucket. `bucket`: always wait for the bucket |
667| `CELLD_LOG_PIPELINE` | Fleet log rounds in flight (default: 4) |
668| `CELLD_LOG_HEDGE_MS` | The wait before a second copy of a slow log append. The default is adaptive: 4 times the slowest recent append, at least 250 ms. `0` disables the copy |
669| `CELLD_LTX_TRUNCATE_PAGES` | The WAL size, in pages, at which celld truncates the WAL at the next checkpoint (default: 128, 512 KiB). A database larger than 4 MiB waits until the WAL is larger than the database. `0` disables it |
670| `CELLD_LTX_RETENTION_SECS` | Unset or `0` (default): celld deletes no epoch prefix. A positive value enables [epoch GC](guarantees.md#epoch-gc): the owner deletes the prefixes below the restore base, but keeps its own epoch, the one before it, and each epoch younger than this many seconds. A pass runs at most every 5 minutes. With `CELLD_LTX_HYDRATE_MBPS=0`, a paged cell never qualifies. Epoch GC skips facet streams and needs [list-after-write consistency](guarantees.md#what-the-bucket-must-provide) |
671| `CELLD_LTX_COMPACTION` | `1` (default) creates additive L1 objects, so a takeover reads tens of objects instead of thousands. Set `0` on every node of a mixed fleet until all nodes read v0.5.2 block objects |
672| `CELLD_LTX_COMPACTION_MIN_TXIDS` | The TXID distance that queues an L1 compaction (default: 256) |
673| `CELLD_LTX_COMPACTION_MIN_MB` | The L0 MiB that queue an L1 compaction (default: 32, at most 64) |
674| `CELLD_LTX_COMPACTIONS` | Concurrent L1 compactions per node (default: 2) |
675| `CELLD_LTX_PAGED` | `1` (default): a takeover of a chain of at least `CELLD_LTX_PAGED_MIN_MB` reads pages from the bucket on first use instead of a full download. Until the background fill completes, a page fault blocks the cell's isolate, so a large query can take minutes. Set `0` to download every chain. Set `0` on every node of a mixed fleet with a node before v0.4.1, which permanently refuses a paged cell. The `paged_gate` log event reports when paging turns on or off |
676| `CELLD_LTX_PAGED_MIN_MB` | The chain size, in MiB, from which a restore pages (default: 256; `0` pages every chain) |
677| `CELLD_LTX_HYDRATE_MBPS` | The background fill rate of a paged cell, in MiB per second, one cell at a time per node (default: 16; `0` keeps the cell sparse) |
678| `CELLD_LTX_DURABILITY_TIMEOUT_SECS` | The budget for one durability proof, and for the final snapshot of a handoff (default: 10). A queued write waits at most six budgets. A slow store can need more |
679| `CELLD_TOKIO_THREADS` | Host Tokio worker threads (default: the CPU count). The `host_runtime` log event at startup reports `worker_count` |
680| `RUST_LOG` | The runtime log filter |
681
682An L1 compaction merges at most 256 source objects within a 64 MiB buffer.
683A larger source object spills to temporary files in the cell's local LTX
684directory, so the node needs free disk for the source and the output.
685
686These settings are removed. Remove them from the environment, including an
687empty value or the former default:
688
689| removed setting | current behavior |
690| --- | --- |
691| `CELLD_OUTPUT_GATE` | celld always waits for the durability proof before it acknowledges a write |
692| `CELLD_SHUTDOWN_DRAIN_MS`, `CELLD_DRAIN_TOKEN_WAIT_MS` | Rejected at startup. Use `CELLD_SHUTDOWN_TOTAL_MS` |
693| `CELLD_OTEL_SINK` | Set `CELLD_OTEL=1` for the fleet bucket or set `CELLD_OTEL` to the collector base URL for OTLP |
694| `CELLD_AI_BINDING`, `CELLD_AI_URL` | The AI adapter is removed. Call the provider from application code and remove the AI binding |
695| `CELLD_CLOUD_RESTART_ON_DEPLOY` | A managed deployment adopts the new code in place. Credential rotation can still restart the process |
696| `CELLD_STORAGE_PROBE` | A node always checks the storage contract. A violation prevents startup; an ambiguous transport error produces a warning |
697| `CELLD_EVICTIONS` | A node runs at most four concurrent evictions |
698| `CELLD_LOG_CAPTURE_WORKERS` | A node uses at most eight log capture workers |
699| `CELLD_REBALANCE_BATCH_CELLS` | A balancing batch moves at most 32 idle cells |
700| `CELLD_PRESENCE_SHADOW` | A managed node sends its serving status and owned-cell count. Use `celld diagnose --read-only` to check leases |
701| `CELLD_LOG_BUNDLE` | Fleet durability always bundles uploads |
702| `CELLD_QUEUE_PRODUCER_GROUP_MS` | A Queue owner groups producer calls with a 4 ms timer |
703| `CELLD_LOG_GROUP_COMMIT_MS` | A node waits 1 ms before a fleet log capture when Queue writes are pending |
704| `CELLD_PACED_HANDOFF` | A node always attempts the handoff within `CELLD_SHUTDOWN_TOTAL_MS` |