Diffinery

homeflare/celldpublic

celld/docs/README.md
1176 lines · 67.7 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
14WebSocket connections, sets alarms, and makes outbound connections. Cells
15share no database, so the application divides into cells from the start.
16Each cell runs on one thread: a second request interleaves only while the
17first awaits, and storage operations are synchronous and never interleave,
18so the data in a cell stays consistent.
19
20You run celld as one process on each machine. That process is a **node**,
21and the nodes that share one bucket are a **fleet**. Any node can serve
22any cell, so you add capacity by starting another node against the same
23bucket.
24
25## Cell lifecycle
26
27A cell has the same states as a Durable Object. A **resident** cell is in
28memory: it is **active** while it does work, and **idle** when it waits.
29celld removes an idle cell from memory after `CELLD_IDLE_EVICT_S` seconds
30without work, and earlier under memory pressure or at the residency cap.
31Without `CELLD_IDLE_EVICT_S`, an idle cell stays in memory until pressure
32or the cap removes it. A cell that then keeps its
33hibernatable WebSocket clients, and stays on its node, is **hibernated**.
34A cell that no node holds is **inactive**. An inactive cell is only an
35object in the bucket, so it costs almost zero, and every cell starts in
36this state. A paged activation adds its epoch prefix to the bucket
37immediately, when it uploads its marker. An activation that is not paged
38adds the prefix at its first per-cell upload. With fleet durability, a
39write goes first to the log bundles of the node. The first per-cell
40upload is therefore the first L1 compaction of the activation, a handoff
41snapshot, or a direct upload while the log ensemble of the node is
42degraded. When epoch GC is on and the cell has an older prefix, the owner
43does not wait for `CELLD_LTX_COMPACTION_MIN_TXIDS`. It starts that
44compaction at its next epoch GC pass after the first write, and a pass
45can come up to 5 minutes later. With `CELLD_LTX_COMPACTION=0` the owner
46does not compact, so the prefix waits for one of the other uploads. A
47restore reads only
48the newest epochs of a cell. celld deletes the older prefixes only when
49`CELLD_LTX_RETENTION_SECS` enables epoch GC, so without it the bytes of
50a cell increase with each activation that adds a prefix.
51
52A cell keeps no memory across these transitions, so the constructor
53runs again on the next event. A hibernated cell wakes the same way a
54cold start does, except that its WebSocket clients stay connected and
55it stays on its node.
56
57One 8 GB node holds 1,000 resident cells, so one resident cell costs
58approximately $0.05 each month.
59
60## Ownership and durability
61
62Exactly one node serves a cell at a time. The nodes do not elect a leader
63or keep a membership list: a node claims a cell by writing a small record
64to the bucket. The store accepts the write only if no other node changed
65the record first. Object storage therefore decides who wins, and two nodes
66cannot both claim the same cell. The claim expires unless the node renews
67it, so a failed machine releases its cells without a separate failure
68detector.
69
70celld does not answer a write until the data survives a failure, so no
71write you were told succeeded is ever lost. That guarantee is called
72RPO=0, for a recovery point of zero.
73
74The durability mechanism depends on how many nodes you run. One node
75writes the data to the bucket first, which costs one storage round trip. Two or more
76nodes are faster: the node serving the cell sends each write to another
77node as well, and answers as soon as that node has the data on its own
78disk. celld uploads the data to the bucket afterwards, so the bucket
79still holds the long-term state. Run two or more nodes if write latency
80matters to you; a single node has nobody to send to, so every write waits
81for the bucket. `CELLD_DURABILITY` selects this behavior and defaults to
82`fleet`.
83
84When a node stops, another node takes the cell over. It first collects
85whatever the stopped node had not uploaded yet, so the takeover starts
86from a complete history. The [guarantees](guarantees.md) page
87gives the full mechanism and the exact properties that the bucket must
88provide.
89
90## Alarms
91
92When an event sets an alarm before its response boundary, celld does not send a
93successful response until a durable wake entry covers the alarm. celld does
94not let a later `waitUntil` alarm delay another event's response.
95Each committed installation requires its own publication PUT, including an
96alarm that moves later within the same minute. Each entry has a separate
97identity, so delayed processing of an older alarm state cannot remove the
98entry that covers a newer alarm.
99
100A hibernated cell fires its alarm on the node that owns it. One node in the
101fleet holds the waker role at a time. The waker reads the due wake entries of
102the whole fleet, and it wakes only the cells whose owner node has stopped. Every
103other node wakes only its own hibernated cells, so the alarm load of the fleet
104does not queue on one node.
105
106## What do you build with cells
107
108A cell fits a workload that divides into named, stateful units:
109
110- **Real-time applications.** A multiplayer game, a chat room, or a
111 collaborative document is one cell. The cell holds the WebSocket
112 connections and the state of one room, so the room needs no lock and
113 no external message bus.
114- **Agents.** Each AI agent is one cell. The cell holds the memory, the
115 schedule, and the inbox of one agent in its own SQLite database. An
116 inactive agent has no resident process, so a large agent fleet costs
117 almost nothing between events.
118- **Sharded web applications.** One cell for each user, each tenant, or
119 each device shards the application from the start. The contention of
120 one shared database does not appear, because no shared database
121 exists.
122
123## Contents
124
125- [Cells and nodes](#cells-and-nodes)
126- [Cell lifecycle](#cell-lifecycle)
127- [Ownership and durability](#ownership-and-durability)
128- [Alarms](#alarms)
129- [What do you build with cells](#what-do-you-build-with-cells)
130- [Install](#install)
131- [Configure object storage](#configure-object-storage)
132- [Deploy an application](#deploy-an-application)
133- [Operate D1, KV, and R2](#operate-d1-kv-and-r2)
134- [Start a node](#start-a-node)
135- [Add nodes](#add-nodes)
136- [Shut down and roll out a node](#shut-down-and-roll-out-a-node)
137- [Diagnose a fleet](#diagnose-a-fleet)
138- [List Durable Objects](#list-durable-objects)
139- [Environment variables](#environment-variables)
140- [Services](#services)
141- [Cloudflare compatibility](cloudflare-compat.md)
142- [What celld guarantees](guarantees.md)
143- [Limitations](limitations.md)
144- [Security](security.md)
145- [Telemetry](telemetry.md)
146- [Testing](testing.md)
147- [WebAssembly](wasm.md)
148- [Python Workers](services/workers.md#python-workers)
149
150## Services
151
152Each service page contains a runnable example and the known differences from
153the Cloudflare service.
154
155- [Workers](services/workers.md)
156- [Durable Objects / Cells](services/durable-objects.md)
157- [Durable Object Facets](services/durable-object-facets.md)
158- [KV](services/kv.md)
159- [Queues](services/queues.md)
160- [D1](services/d1.md)
161- [R2](services/r2.md)
162- [Workflows](services/workflows.md)
163- [Cron Triggers](services/cron-triggers.md)
164- [Static assets](services/static-assets.md)
165- [Dynamic Workers](services/dynamic-workers.md)
166- [Containers](services/containers.md)
167
168## Install
169
170The installer downloads the `celld` binary. Replication runs inside the
171celld process, so a node needs no external replicator.
172
173```sh
174curl -fsSL https://celld.dev/install.sh | sh
175```
176
177If the installer tells you, add `~/.local/bin` to `PATH`. To install one
178exact release, set `CELLD_VERSION` to its tag, for example `v0.0.1`; to
179go back, run the installer again with the previous tag. The releases are
180on [GitHub](https://github.com/denoland/celld/releases), and each release
181has a GitHub Actions build attestation: verify a downloaded file with
182`gh attestation verify <asset> --repo denoland/celld`.
183
184## Configure object storage
185
186The `s3://`, `gs://`, and `az://` scheme names are case-insensitive.
187celld ignores leading and trailing whitespace in `CELLD_BUCKET`.
188
189For an S3-compatible bucket, celld uses the standard AWS credential
190chain. Paged restores also use this chain, so an EC2 instance role does
191not require static access keys for a large cell. On Amazon EKS, celld
192reads the Pod Identity credentials from the injected environment
193variables and the authorization-token file. For Cloudflare R2: create
194a bucket, create an S3 API token with access to
195that bucket, and set these variables:
196
197```sh
198export AWS_ACCESS_KEY_ID=...
199export AWS_SECRET_ACCESS_KEY=...
200export AWS_REGION=auto
201export S3_ENDPOINT=https://ACCOUNT_ID.r2.cloudflarestorage.com
202export CELLD_BUCKET=s3://YOUR-BUCKET
203```
204
205For Google Cloud Storage, celld uses Application Default Credentials.
206Create a bucket. Then authenticate with `gcloud auth application-default
207login`, or point `GOOGLE_APPLICATION_CREDENTIALS` at a service-account
208key that has access to the bucket. Then set the bucket:
209
210```sh
211export CELLD_BUCKET=gs://YOUR-BUCKET
212```
213
214A `gs://` bucket takes no `S3_ENDPOINT` and no `AWS_*` credentials, and
215celld ignores the storage region. On a Compute Engine instance, celld can
216use the attached service account, but the access scopes of the instance
217cap this credential, and the default scope permits only storage reads.
218Create the instance with the `cloud-platform` scope, so the IAM role of
219the service account controls the access.
220
221For Azure Blob Storage, the bucket NAME is the container, and the
222storage account comes from the environment. Create a container. Then
223set the account and one credential:
224
225```sh
226export AZURE_STORAGE_ACCOUNT_NAME=YOUR-ACCOUNT
227export AZURE_STORAGE_ACCOUNT_KEY=...
228export CELLD_BUCKET=az://YOUR-CONTAINER
229```
230
231You must configure exactly one Azure credential family: a storage account
232key, a managed identity, or a workload identity. A system-assigned managed
233identity needs only the account name. A user-assigned managed identity needs exactly one selector among
234`AZURE_CLIENT_ID`, `AZURE_OBJECT_ID`, and `AZURE_MSI_RESOURCE_ID`,
235because two selectors can name two different identities. An identity
236must hold the Azure Blob data-plane permission to read, write, list, and
237delete blobs; the built-in
238[`Storage Blob Data Contributor`](https://learn.microsoft.com/azure/role-based-access-control/built-in-roles#storage-blob-data-contributor)
239role supplies it.
240
241celld reads a managed identity from the Azure instance metadata service,
242which an Azure VM and an AKS node supply. Azure App Service and Azure
243Container Apps supply a different endpoint, so a managed identity does
244not work there; use a workload identity or an account key instead. The
245standard AKS workload identity environment (`AZURE_AUTHORITY_HOST`,
246`AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_FEDERATED_TOKEN_FILE`)
247works with the public authority host, `https://login.microsoftonline.com`,
248with or without a trailing slash; celld rejects a sovereign or custom
249host. celld also rejects each recognized Azure configuration variable
250outside these families, including another credential source, an endpoint
251override, or the OneLake endpoint. It ignores an `AZURE_*` name that
252`object_store` 0.12 does not recognize, because that name cannot change
253the client.
254
255An `az://` bucket takes no `S3_ENDPOINT` and no `AWS_*` credentials, and
256celld ignores the storage region. celld qualifies an `az://` bucket for
257a production fleet. The startup test verifies the conditional writes and
258ranged reads. A live Azure test from 2026-08-18 covers the multipart upload
259path. See [guarantees](guarantees.md). For local development against Azurite,
260set `AZURE_STORAGE_USE_EMULATOR=true`; Azurite is a development store, so
261celld does not qualify it for a fleet either.
262
263The bucket credentials give full control of the fleet, so keep them
264safe. The bucket contains the deployments, the SQLite replicas, the
265ownership records, the node leases, and the peer-authentication secret.
266
267A bucket value can add a key prefix: `s3://YOUR-BUCKET/PREFIX`. Every
268object of the fleet then goes below `PREFIX/`, so two fleets can share one
269bucket. A bucket value without a prefix keeps the objects at the root of
270the bucket, therefore an existing fleet does not move its data.
271
272The store must provide conditional writes. A ranged read must return the
273exact requested bytes. The store must also provide read-after-write
274consistency. Cell ownership and stored data depend on these properties.
275Amazon S3, Cloudflare R2, Google Cloud Storage, Tigris, and Azure Blob Storage
276qualify; Backblaze B2, Hetzner, and DigitalOcean Spaces do not. MinIO
277(the community edition) passes the storage test, but celld has not
278qualified it for production; do not use RELEASE.2025-09-06T17-38-46Z,
279which rejects the conditional create that the first deploy sends
280(denoland/celld#162). See [what celld guarantees](guarantees.md) for the
281exact requirements.
282
283## Deploy an application
284
285If the project contains Worker code, install `esbuild` on `PATH`; an
286asset-only project does not need it. Then run `celld deploy` from an
287applicable Wrangler project:
288
289```sh
290git clone https://github.com/denoland/celld
291cd celld/examples/counter
292celld deploy . \
293 --bucket "$CELLD_BUCKET" \
294 --endpoint "$S3_ENDPOINT" \
295 --region "$AWS_REGION"
296```
297
298`celld deploy` accepts module Workers, Durable Object bindings, service
299bindings, variables, cron triggers, D1 databases, KV namespaces, Queues,
300R2 buckets, Workflows, WebAssembly modules, and static assets. An asset project can include a
301Worker or be asset-only, and the asset functions include the assets
302binding, HTML handling, not-found handling, worker-first routes,
303`_headers`, and `_redirects`. If the Wrangler configuration contains an
304unknown key, the deploy stops with an error. See the
305[Cloudflare compatibility](cloudflare-compat.md) page for the complete
306deployment boundary.
307
308A new deployment manifest records the full SHA-256 digest of each JavaScript
309or WebAssembly module. A node verifies each module before it builds the
310deployment, so changed module bytes cannot become active. A node also accepts
311a legacy 16-character digest and verifies that prefix, so an upgrade can load
312an existing deployment.
313
314A running node does not restart for a new deployment. Each node reads
315`deploy/current.json` every 30 seconds (`CELLD_DEPLOY_POLL_S`) and adopts
316a new deployment in place, and `POST /reload` on the internal listener
317makes a node adopt the pointer now. A node builds the new deployment
318beside the one it serves, and then it switches new requests to the new
319deployment in one step. A request that started on the previous deployment
320finishes on it. A deployment that does not build leaves the current
321deployment serving, and the node reports the failure in its log and in
322the `/reload` response. `POST /reload` also rebuilds an unchanged
323deployment.
324
325A Durable Object that is not resident runs the new deployment at its
326next activation. A resident Durable Object moves to the new deployment
327at a safe point: no request runs in it, no alarm handler runs in it, no
328output waits for durability, and no regular WebSocket is open. A request
329that arrives while the object moves waits for the new code. The move
330keeps the object's storage, its epoch, and its hibernatable WebSockets,
331and it does not read or write the bucket. An object that reaches no safe
332point in `CELLD_DEPLOY_MAX_AGE_S` seconds (default 60) is forced: celld
333cancels its running work and closes its regular WebSockets with code
3341012, which is what a Cloudflare deployment does to every object. A
335value of 0 forces every resident object at the adoption. In this window,
336a request on one deployment can call a Durable Object on the other, so
337two adjacent versions must accept each other's calls. The `/state`
338response reports the deployment a node serves, the deployments it still
339drains, the objects that are moving, and the deployment each resident
340object runs.
341
342## Develop an application locally
343
344Run `celld dev` in a Wrangler project:
345
346```sh
347celld dev
348```
349
350The command opens a local object store, deploys the application, and starts
351one celld node. It does not require Docker or a cloud bucket. The supervisor
352stops the node when the command finishes or returns an error. On Linux, the
353kernel also stops the node if the supervisor exits abruptly.
354
355The Worker listener uses `http://127.0.0.1:9876` by default. Use `--port` to
356select a different port:
357
358```sh
359celld dev --port 3000
360```
361
362Use `--host` to select the Worker listener interface:
363
364```sh
365celld dev --host 0.0.0.0
366```
367
368A non-loopback IP exposes the Worker listener to the network. The internal
369operator listener stays on loopback, so another machine cannot use its
370operator API.
371
372The default display uses color to identify each status and the application
373URL. It hides the node warning and information logs, so the errors and the
374listener remain easy to find. Use `--logs` to show these logs:
375
376```sh
377celld dev --logs
378```
379
380Set `NO_COLOR` to disable color. Set `FORCE_COLOR` to enable color when
381the output is not a terminal. `NO_COLOR` always takes priority when both
382variables are set.
383
384You can also give the command a project directory or a Wrangler
385configuration file:
386
387```sh
388celld dev ./examples/counter
389```
390
391The command reads a `.dev.vars` file beside the Wrangler configuration, as
392`wrangler dev` does. Each line of the file has the form `NAME=value`. A
393value can be wrapped in double or single quotes, and the command removes
394the quotes. The command does not read the other dotenv features, such as a
395comment after a value or a value on more than one line. An entry becomes a
396Worker variable, and it overrides an entry of the same name in the `vars`
397of the configuration. Only `celld dev` reads the file, so a local
398credential does not reach a fleet through `celld deploy`. Add `.dev.vars`
399to the application's `.gitignore` file. A change to the file rebuilds the
400application, so a new value takes effect without a restart. The command
401writes each value into the local deployment record under `.celld/dev`, and
402`--clean` deletes that record.
403
404The command stores the local objects and the celld work files in `.celld/dev`
405below the project directory. Add `.celld/` to the application's `.gitignore`
406file. A normal shutdown keeps this directory, so the next invocation uses the
407same durable application state.
408
409This persistence holds across a configuration change, and celld does not
410migrate the stored state to match the new configuration. An object therefore
411keeps a value that the previous configuration wrote, and the application can
412reject that value and fail. The error names the stored value and not the
413configuration, so the failure can look unrelated to the change you made. Use
414`--clean` to start the command from an empty local state:
415
416```sh
417celld dev --clean
418```
419
420The flag deletes `.celld/dev` before the server starts, and it deletes nothing
421else below `.celld`. The command reports the outcome on the console. An absent
422`.celld/dev` directory is the wanted result, so the flag succeeds on a project
423that never ran `celld dev`.
424
425The command does not expose the local object store through a fleet flag. A
426regular node or an operator subcommand must use a supported cloud bucket.
427
428The command watches the project directory. A source or configuration
429change builds a new deployment and restarts the local node. The current
430application continues to run during the build, and a failed build does
431not replace it. The restart retains the durable application state.
432
433A read of a project file is not a change, so a tool that only reads the project
434does not start a build.
435
436The watcher ignores `.celld`, `.git`, `.wrangler`, `node_modules`, and `target`
437directories at each depth. Use `--watch-ignore PATTERN` to ignore an additional
438project-relative glob, and repeat the option to add more globs. The
439`--watch-ignore` option cannot be used with `--no-watch`. Use `--no-watch` to
440disable all automatic builds and restarts.
441
442The watcher does not watch a source file outside the project directory. Worker
443projects need `esbuild` on `PATH`, and asset-only projects do not need it.
444
445## Operate D1, KV, and R2
446
447`celld d1` runs SQL and migrations against a deployed D1 database. The
448command uses the fleet bucket to find a node, and the node routes the
449operation to the database cell.
450
451```sh
452celld d1 migrations apply ledger --bucket "$CELLD_BUCKET"
453```
454
455The `migrations_dir` value must be a relative path inside the project. An
456absolute path or a path with a `..` component is invalid.
457
458`celld kv` reads and writes a deployed KV namespace. The bulk commands use
459the Wrangler file format, so `wrangler kv bulk get` can export data for
460`celld kv bulk put`.
461
462```sh
463celld kv bulk put sessions wrangler-export.json --bucket "$CELLD_BUCKET"
464```
465
466`celld kv bulk get` writes each row before it reads the next value, so the
467command does not retain the complete namespace. A named output file changes
468only after the export completes. If a stdout export fails, the output remains
469an incomplete JSON array and a consumer cannot import it as a complete export.
470
471`celld kv list` prints at most 1000 keys, because a namespace can hold
472many more keys than an operator wants to read. The command reports on
473stderr that more keys exist, and it gives the `--after KEY` that continues
474the listing. Pass `--all` to read every key, or `--json` for one JSON
475object per key.
476
477`celld r2` reads and writes the objects behind an `r2_buckets` binding. The
478binding serves the fleet bucket under the reserved `r2/<bucket_name>/`
479prefix, and this command reads the same prefix directly. It therefore needs
480no running node, so a release pipeline can publish an artifact before it
481deploys the Worker.
482
483```sh
484celld r2 put assets app.zip --path dist/app.zip \
485 --content-type application/zip \
486 --metadata '{"release":"1.2.3"}' \
487 --bucket "$CELLD_BUCKET"
488```
489
490The first argument is the `bucket_name` from the project's `r2_buckets`
491entry, not the binding name. An object this command writes carries the same
492record as an object `env.BUCKET.put()` writes, so `--metadata` becomes
493`customMetadata` and the content flags become `httpMetadata`. Another tool
494can write an object into the prefix, and the binding still reads it: the
495object's user metadata becomes its `customMetadata`, and its headers become
496its `httpMetadata`. Such an object carries no `cacheExpiry` and no
497checksums, because a store has no place for either.
498
499`celld r2 get` writes the object to stdout as bytes, and it reads the body
500as a stream, so an artifact larger than the available memory still
501transfers. `celld r2 list` prints at most 1000 keys and reports on stderr
502how to continue, the same as `celld kv list`. The `celld r2 head` command
503prints the object's stored record. With `--json`, the `http` and `custom`
504fields contain the binding's `httpMetadata` and `customMetadata` values.
505
506Every celld command writes its data to stdout and its messages to stderr,
507so a redirect or a pipe carries only data:
508
509```sh
510celld kv list sessions --all --json --bucket "$CELLD_BUCKET" > keys.ndjson
511```
512
513`celld --help`, `celld --version`, and the listener announcements use the same
514stdout sink. The sink treats a closed pipe as a successful stop, and it reports
515all other write and flush errors.
516
517## Start a node
518
519For local development, the default listener is sufficient:
520
521```sh
522celld \
523 --bucket "$CELLD_BUCKET" \
524 --endpoint "$S3_ENDPOINT" \
525 --region "$AWS_REGION"
526```
527
528For a fleet node, bind the public and internal listeners separately. The
529ingress can reach the public listener, and the other nodes can reach the
530internal listener:
531
532```sh
533celld \
534 --bucket "$CELLD_BUCKET" \
535 --endpoint "$S3_ENDPOINT" \
536 --region "$AWS_REGION" \
537 --listen 0.0.0.0:8080 \
538 --internal-listen 10.0.0.12:8081 \
539 --advertise node-a.internal:8081
540```
541
542An explicit advertised address requires an explicit internal-listener
543address: set both command-line options, or their equivalent environment
544variables. celld also rejects an explicit non-loopback public listener
545without an explicit internal listener, because that shape identifies an
546obsolete one-listener configuration.
547
548celld cannot verify that an advertised hostname or a translated port
549reaches the internal listener. You must route the advertised address to
550the internal listener, and you must not route it to the public Worker
551listener.
552
553## Add nodes
554
555Start each node with the same bucket settings. Give each internal listener
556a different address that the other nodes can reach, and set `--advertise`
557to that address. The nodes find each other through the leases in the
558bucket; there is no join command and no fixed membership list.
559
560The bucket supplies discovery and authority, not network reachability.
561Cell fetch and RPC traffic has a protocol version but has no content
562signature, so the private network and its code are the security boundary.
563Peer-control and reserved-cell operator requests use the fleet HMAC, but celld does not
564terminate TLS. Put the advertised addresses on a private network that you
565trust, or use an encrypted overlay such as WireGuard or Tailscale. The
566internal listener also has an unauthenticated operator API, so it must not
567reach the public internet. See the [security](security.md) page for the
568complete boundary.
569
570The listener that receives a request decides where a new cell activates,
571so a load balancer must include a new node in its rotation. A node below
572its residency cap keeps every cell that activates on it. A node at its
573cap, and a node that sheds under memory pressure, hands the activation to
574the peer with the lowest load, and an empty node wins that comparison. A
575shed eviction releases the ownership record
576(`CELLD_PRESSURE_OWNERSHIP=release`, the default), so the next request
577can move the cell. An idle eviction keeps the ownership record, so an
578idle cell wakes on its own node. The node proves the cell durable before
579it stops the runtime, and the cell answers requests through that proof. A
580request that arrives before the stop therefore cancels the eviction, and
581the cell keeps its runtime and its epoch. A bucket proof confirms the
582cell's objects before the stop, so it makes this first window longer than
583a fleet proof does. A request that arrives during the stop can also keep
584the epoch. The node stops the runtime, and then it writes a handoff
585snapshot to the bucket. Before that write the node has published nothing,
586so it gives the cell back and starts it again on the same database at the
587same epoch. After that write the snapshot is the restore source for the
588next owner, so a request waits for the cell to start again at a new
589epoch. The two durability postures behave the same way during the stop,
590because both write the same snapshot at the same point. An idle eviction
591must stop the runtime within `CELLD_OPERATION_DEADLINE_MS`. If the
592runtime does not stop in time, the node keeps the cell resident at its
593current epoch. The node waits one more idle period before the next
594attempt, and it waits the same period after it gives a cell back.
595
596A new node also receives existing idle cells. Every node reads a shared
597fleet sample every five seconds (`CELLD_REBALANCE_INTERVAL_MS`; `0`
598disables balancing). One node claims each refresh through a conditional
599write and reads the node leases for the fleet. The other nodes read
600the result from `fleet/capacity-v1.json`. A node judges the leases in a
601sample at the moment the sample was taken, because the copied leases age
602while the nodes renew the originals. A sample expires after one
603configured interval. A node that reads during a refresh keeps the
604previous sample while that sample is less than three intervals old. A
605refresher that fails puts the previous sample back, so the next reader
606refreshes at once. A refresher that stops holds its claim for three
607intervals, or for 30 seconds if that period is shorter. This claim
608lifetime does not exceed the maximum accepted age of a previous sample.
609A stopped refresher can leave the other nodes without a sample until the
610claim expires. An unavailable sample stops balancing and closes the
611bucket-format gate.
612With balancing disabled, the format check still reads the shared sample
613every five seconds. A node that hands an activation to a peer reads the
614same shared sample, so a burst of activations at a full node costs one
615read each. Readiness, a drain, follower recruitment, and lease authority
616read the node leases directly.
617
618Each node has an ownership target: the fleet's owned cells, divided in
619proportion to the node weights
620(`CELLD_PLACEMENT_WEIGHT`, default: the CPU count). The node with the
621most owned cells per unit of weight hands at most 32 idle cells
622to the peer that is furthest below its
623target, and it hands over no more cells than the receivers have room
624for. A receiver fills to 2% below its target, so a stale sample cannot
625make two nodes trade the same cells. Only a hibernated cell moves. Its
626move is one ownership record write and one signed acquire, it stays
627hibernated on the new owner, and its parked hibernatable WebSockets close
628with code 1012 so the clients reconnect to the new owner. A resident cell
629does not move: it hibernates through idle eviction first
630(`CELLD_IDLE_EVICT_S`) and moves after. Therefore a fleet without idle
631eviction balances only the cells that hibernate on their own. A request
632that arrives for a moving cell waits for the new owner and then follows
633the normal route to it. A node that drains receives no cell, and a node
634with cold activations queued behind its activation ceiling (`restoring` in
635its lease) receives no cell until that backlog clears. The fleet moves nothing while a
636node reports a lease without a weight, so a rolling upgrade to this
637version completes before the first move. An operator can pause the fleet with
638`POST /rebalance/pause` on the internal listener of any node.
639
640## Feed an autoscaler
641
642celld does not scale itself. An external system starts and stops the
643nodes, and celld hands the cells off. Two surfaces report the numbers
644that a scaling decision needs.
645
646Each node writes its lease to `nodes/<node>.json` in the bucket, and
647each renewal refreshes it (`CELLD_TTL_MS`, default 10000, renewed at
648one third of the lifetime). The lease carries a load block:
649`owned_cells`, `placement_weight`, `resident_cells`, `host_websockets`,
650`rss_bytes`, `in_use_bytes`, `cpu_percent_x100`, `open_fds`, `pressured`,
651`memory_headroom`, `shed_cells`, and `restoring`. A script can read these
652objects with the
653bucket credentials alone, and `sampled_ms` dates each sample. The
654`owned_cells` value includes the dormant cells and the cells that are waking
655from dormancy. A started node omits the value until it has read the
656ownership record of every cell on its own disk, so a restarted node does
657not report an empty node while it still owns its hibernated cells. The
658`resident_cells` value includes only the cells that consume the local
659runtime capacity.
660
661The shared runtime samples the process memory, open files, and CPU every
662second, and once before the first lease acquisition. The lease and `/state`
663report these values from the latest sample, so they are normally one sample
664period old. The `allocator` and `libc_malloc` objects in `/state` are read
665when the request arrives.
666
667The internal listener answers `GET /state` with the live counters:
668`owned_cells`, `occupied`, `capacity_waiting`, `activation_waiting`, `restoring`,
669`shedding`, and the memory values. The `allocator` object reports the
670Rust allocator's own counters in bytes: `allocated_bytes` is the memory
671that Rust code holds, `resident_bytes` adds the freed pages that the
672allocator keeps for reuse, and `mapped_bytes` and `retained_bytes` are its
673address space. V8 maps its heaps itself, so `rss_bytes` includes them and
674`allocated_bytes` does not. On Linux the `libc_malloc` object reports the
675C allocator that SQLite and V8 use: `in_use_bytes` is what they hold, and
676`free_bytes` is what glibc keeps for them after a free. The `handed_off` counter is the number of
677cells this node gave to a peer, `rebalanced` is the part of that number
678that balancing moved, and `rebalance_failed` is the number of balancing
679moves that no peer acquired. A positive `capacity_waiting` means
680that the node queues activations behind its residency cap, and that is
681the direct signal to add a node. A `pressured` lease is the memory form
682of the same signal. Scale down only when every remaining node reports
683`memory_headroom` and a small `restoring` backlog. A drain into a fleet
684without spare capacity parks the cells dormant on the survivors, and
685each later activation must then shed a resident cell to run.
686
687The `remote_route_refreshes` counter counts cached owner or capacity routes
688that expire and start a new lookup. It increases once for each retired
689route, so it also increases during normal lease renewal. An adoption
690without a lease and an explicit invalidation do not increase it.
691
692The `deployment.isolates` object reports the V8 isolates of the current
693deployment, and each entry of `deployment.draining` reports the isolates
694of one superseded deployment. The `cells` map has one entry for each
695Worker script, and the `stateless` and `services` entries cover the
696request handlers. Each entry counts the isolates that accept work
697(`live`), the live isolates that house no cell (`live_empty`), the
698retiring isolates that still hold a heap (`retiring`), and the freed
699slots (`freed`), with the cells, requests, and turns that they hold.
700`heap_bytes` is the physical memory that V8 has committed to those heaps,
701and `external_bytes` is the memory that the isolates track outside them. A
702dormant cell holds no isolate, and celld retires an empty cell isolate on
703its next maintenance pass, so a `live_empty` count that persists for more
704than 30 seconds means that the pass does not run. A `retiring` count that
705persists means that a turn or a request still holds the heap.
706
707The public `/.well-known/celld/health` path stays a boolean. It reports
708503 during a drain and before a joining node settles, so an
709orchestrator can gate a rolling update on it, but it carries no
710utilization number.
711
712## Shut down and roll out a node
713
714celld shuts a node down gracefully on SIGTERM or SIGINT, the signals that
715`systemctl stop`, `docker stop`, and a Kubernetes pod delete send. The
716`/.well-known/celld/health` path reports the node as unhealthy, so a load balancer
717stops public routing to it. New public requests receive a 503 response,
718and celld closes each connection so the client can retry on a healthy
719node. The node finishes the public HTTP requests that it accepted before
720shutdown, and it continues to accept versioned peer traffic for cells that
721it has not handed off.
722
723You must set a longer orchestrator stop grace, such as systemd
724`TimeoutStopSec` or Kubernetes `terminationGracePeriodSeconds`. The grace
725must cover the drain-token wait, the expected complete handoff, and one
726no-progress interval (the settings below). Otherwise, the orchestrator
727can send SIGKILL before celld completes the handoff.
728
729The handoff works in batches. The node reserves a batch of cells and
730stops new local routes to them: an accepted request stays local until it
731finishes, and a new request waits for the successor route. The node
732also cancels each firing alarm in the batch. The alarm runtime records a retry
733and arms its wake entry, so the successor can run the alarm at least once.
734The node cancels an active internal fetch or RPC handler before the durability
735proof, so a Queue broker cannot retain the batch until the process stops.
736The node proves the batch durable in the live durability ensemble, and it
737then closes each database. The node publishes one full L9 snapshot of the
738closed database and verifies that the bucket contains a restore object. The
739successor therefore does not replay the complete transaction history. If the
740snapshot fails, the node materializes the additive L0 chain within the same
741durability deadline. A database larger than the deadline can upload, 80 MiB
742at the default deadline of 10 seconds, skips the snapshot and hands off
743through its L0 chain at once, and a snapshot that fails once is not retried
744for that cell. The node does not release the cell unless one complete
745restore path is visible. The node then releases each ownership
746record and asks a
747compatible peer to acquire it. The peer acknowledges after the ownership
748update and keeps the cell dormant, so the handoff does not restore an
749unused runtime; a later request starts the cell under the peer activation
750limit. The donor starts the next batch after each acknowledgement.
751
752celld orders the resident cells by their local request count. The newest local
753request ID resolves an equal count, and the cell ID resolves an unused cell.
754Therefore, a total stop bound moves shared resources before one-time resources.
755
756`CELLD_RELEASES` limits the complete handoffs in progress (default 128).
757Each handoff includes activity cancellation, a durability proof, a final
758snapshot, an ownership release, and a successor update. `CELLD_ACTIVATIONS`
759limits the demand-driven restores and the startup work.
760
761`CELLD_SHUTDOWN_TOTAL_MS` sets the complete process stop bound (default
76240000 ms). The orchestrator stop grace must exceed this bound, so celld can
763finish its local durability shutdown. celld derives its internal waits from
764this one value. The token wait is three quarters of the bound (default
76530000 ms). The handoff no-progress interval is five eighths of the bound
766(default 25000 ms), with a minimum of one millisecond. Fractional milliseconds
767are rounded down before the minimum applies.
768
769Each successor acknowledgement restarts the no-progress interval. The total
770stop bound still limits the complete shutdown, so progress cannot extend the
771process lifetime beyond the configured grace. A handoff reserves the smaller
772of one second and ten percent of the total bound for the drain-token release.
773A same-node preserve operation uses the no-progress interval as its semantic
774limit because it has no successor acknowledgements. The token-release reserve
775does not apply to a same-node preserve.
776
777celld rejects the removed `CELLD_SHUTDOWN_DRAIN_MS` and
778`CELLD_DRAIN_TOKEN_WAIT_MS` variables at startup. Remove these variables and
779set only `CELLD_SHUTDOWN_TOTAL_MS` when the default total bound is unsuitable.
780The `CELLD_PACED_HANDOFF` switch is also removed. A bucket-backed node
781attempts ownership handoff within this budget. If no successor can accept
782the cells, the existing no-progress and total stop bounds still apply.
783
784Simultaneous stop signals do not flood the surviving nodes. A draining node
785claims a fleet drain token before it releases cells, so concurrent donors
786hand off one node at a time. A donor that cannot claim the token within its
787derived wait proceeds without it because the orchestrator grace is finite.
788The token is advisory: a dead holder's claim expires, and a handoff without
789the token is still safe.
790
791A fresh process also holds its first healthy response until the fleet is
792settled. The process requires its live node lease, no active donor, and memory
793below every pressure low watermark on each live node. A donor records each
794node's restore backlog before it releases ownership. The replacement permits
795one `CELLD_ACTIVATIONS` budget above each recorded value. The incumbent
796ownership counts must remain within one equal successor share above the fleet
797mean. A joining process can satisfy this condition when it advertises paced
798handoff support and owns fewer cells than the busiest incumbent. The process
799publishes this successor capacity before readiness, so an idle rollout can
800repair the ownership distribution during the next donor handoff.
801
802An initial spare has no drain token, so it has no rollout restore baseline to
803check. It still requires memory headroom and acceptable ownership distribution.
804
805An older peer does not publish the low-watermark result, so the gate uses that
806peer's pressure latch during a mixed-version update. An unreadable fleet or an
807unsettled condition keeps the process unhealthy until the condition clears.
808`CELLD_READY_FLEET_GATE_MS` sets the observation deadline in milliseconds
809(default 120000; `0` disables the gate). celld emits `ready_gate_expired` once
810at that deadline, but readiness stays closed. Set an orchestrator rollout
811deadline so a persistent capacity problem fails the rollout. After the first
812healthy response, fleet state does not remove readiness again.
813
814A deadline-cut handoff can leave a node-log recovery for the replacement.
815One process reads and uploads that dead session, and the other processes wait
816for its result. A waiting process can replace an unresponsive recovery after
81730 seconds, so a failed recovery cannot block the fleet permanently. A
818recovery store error keeps the session unsealed, so a later recovery must read
819every retained bundle before the replacement can restore the acknowledged
820state.
821
822Recovery records a checkpoint after each group of 32 completed cell epochs.
823A later attempt uses these checkpoints to skip repeated coverage checks and
824uploads for the recorded transactions. Each checkpoint follows the data uploads,
825so an interrupted upload cannot create a checkpoint for incomplete data.
826An unavailable or invalid checkpoint causes recovery to check the cell coverage
827again. A checkpoint write failure does not stop recovery. The checkpoints do
828not replace the follower evidence or the session seal, and different sessions
829continue to recover independently.
830
831The internal listener continues to accept `/state` requests during the
832drain, and the response reports the handoff and restore counters. The
833public health response identifies the active drain with a 503 status.
834
835A remote cell call can resolve an owner generation that a replacement process
836rejects. celld then waits for a different `(node, epoch)` and refreshes the
837route. The wait uses `CELLD_OPERATION_DEADLINE_MS` as its total bound (default
83815000). celld retries only a peer attempt that proves that the handler did not
839start. It does not retry an ambiguous attempt because the handler can have
840completed without returning its response.
841
842A marked stale-owner response to the outer peer tunnel proves that the
843application request did not start. celld can therefore refresh that route for
844an HTTP, an RPC, or a WebSocket request.
845
846An application must keep one stable operation ID when it retries an ambiguous
847fetch, RPC, D1, or service operation. A WebSocket transport cannot move between
848owners, so a client must reconnect and keep the same application operation ID.
849
850To roll out a new version, use the rolling update of your orchestrator:
851stop each node with SIGTERM, wait for its replacement to report healthy,
852then move to the next node. celld paces the cell handoffs inside each node
853shutdown, and the first-readiness gate paces the update against fleet
854recovery, so a deployer does not need a separate fleet-level handoff gate.
855
856Some upgrades are exceptions:
857
858- The upgrade from v0.1.0 to v0.2.0 must not be a rolling update. Stop
859 every v0.1.0 node, then start the v0.2.0 nodes. Two changes require
860 this: v0.2.0 nodes advertise the internal listener, so ownership
861 records that v0.1.0 nodes wrote name an address that v0.1.0 peers can
862 not follow to a v0.2.0 node; and v0.2.0 compacts replicated data into
863 block objects that a v0.1.0 reader can not restore. A fleet must not
864 mix the two versions.
865- The upgrade from v0.2.1 to v0.3.0 can use a rolling update. v0.3.0
866 changes the default durability from `bucket` to `fleet`: a single node
867 keeps the v0.2.1 behavior, and a fleet of two or more nodes activates
868 fleet replication automatically. Stage the v0.3.0 binary on every node,
869 and restart one node at a time. A mixed fleet stays safe, but a v0.3.0
870 node cannot replicate to a v0.2.x peer, so it acknowledges writes
871 through the bucket and retries until the peer runs v0.3.0. Do not start
872 a v0.2.x binary after that node runs v0.3.0 unless the shutdown log
873 contains `node-log close: sealed epoch`. A graceful stop attempts this
874 seal, but a stop under load can leave the record open, and a v0.2.x
875 binary cannot read writes that wait in the replicated log or bundle
876 objects. Therefore, this downgrade can lose acknowledged writes.
877- The upgrade from v0.3.0 to v0.4.0 must not use a rolling update. Stop
878 every v0.3.0 node, and then start the v0.4.0 nodes. v0.4.0 moves every
879 proxied fetch, RPC, and WebSocket call onto one tunneled connection that
880 carries plain HTTP. The peer protocol refuses a different version, so the
881 two versions cannot proxy calls to each other. v0.4.0 also stores each new large KV value under its ownership
882 epoch and writes an epoch-qualified row reference. A v0.3.0 node cannot
883 read that reference, so a mixed fleet can make a committed KV value
884 unavailable. The tunnel establishment carries the version, so a later
885 protocol change can negotiate instead of refuse.
886- The upgrade from v0.4.0 to v0.4.1 can use a rolling update. v0.4.1
887 restores a large cell by paging, and a paged epoch continues the chain
888 of the epoch before it instead of opening with a whole-database snapshot.
889 A v0.4.0 node cannot restore such an epoch. Each v0.4.1 node therefore
890 publishes the bucket format it reads in its lease, and it pages a
891 takeover only while every live lease reads that format. A v0.4.1 node in
892 a mixed fleet clones a large cell the way v0.4.0 does, and paging starts
893 on its own one lease lifetime after the last v0.4.0 node stops. Do not
894 start a v0.4.0 binary after that point: a cell that paged in has no
895 epoch a v0.4.0 node can restore, and it stays unavailable on that node
896 until a v0.4.1 node takes it over.
897- The upgrade from v0.5.1 to v0.6.0 must not use a rolling update when
898 the fleet uses `fleet` durability. Stop every v0.5.1 node, and then start
899 the v0.6.0 nodes. A v0.6.0 node recovers its previous log session only
900 when a follower returns the ranged tail format. A v0.5.1 follower returns
901 the entries-only format, so the v0.6.0 node refuses to start. A fleet
902 that uses `bucket` durability has no followers, so it can use a rolling
903 update.
904- The upgrade from v0.6.0 to v0.6.1 can use a rolling update. Do not set
905 `CELLD_LTX_RETENTION_SECS` on a node until every node runs v0.6.1. A
906 v0.6.0 node does not read `cells/<cell>/ltx/retired.json`, so it treats
907 the rows of a deleted epoch as unstored. That node keeps those bundle
908 rows, it cannot seal its log at shutdown, and its next start uploads the
909 rows again. No data is lost, but storage use and recovery time increase.
910 A v0.6.0 node refuses a Python Workers deployment, so deploy a Python
911 application only after every node runs v0.6.1. A v0.6.0 node also refuses
912 an asset index with a file larger than 25 MiB. Therefore, raise
913 `CELLD_MAX_ASSET_FILE_BYTES` above that size only after every node runs
914 v0.6.1. A rollback to v0.6.0 can
915 also use a rolling update. Unset `CELLD_LTX_RETENTION_SECS` on every node
916 first, so that no v0.6.1 node deletes an epoch while a v0.6.0 node runs.
917
918The internal listener also provides an alpha operator API. `/state`
919reports the node state, and its `node_load` object is the same load sample
920that the node lease publishes. `POST /reload` adopts the deployment pointer now,
921and `POST /shutdown` starts the same graceful
922handoff. `POST /rebalance/pause` stops balancing. The node publishes the
923pause in its lease, and one paused lease stops every move in the fleet, so
924a pause on one node pauses the fleet. `POST /rebalance/resume` on the same
925node resumes it. The `POST /shutdown?handoff=preserve` request prepares a clean
926same-node reload and keeps the ownership records. The preserve operation cancels
927a cold activation, including a wait for a recovery retry, because the activation
928has no runtime to retain. celld writes the reload marker
929only after it uploads each stopped database position to the bucket. If an upload
930fails, the next process uses the normal recovery path. A release can change this
931API, so keep the operator tooling and the celld release together.
932
933## Diagnose a fleet
934
935`celld diagnose` reads the node leases in the bucket and sends a probe to
936each live peer. It does not take a lease, and it does not change
937ownership.
938
939```sh
940celld diagnose \
941 --bucket "$CELLD_BUCKET" \
942 --endpoint "$S3_ENDPOINT" \
943 --region "$AWS_REGION"
944```
945
946To probe only some nodes, use `--peer NODE_ID` one or more times. The
947report identifies expired records, unsafe or incorrect advertised
948addresses, peers that it cannot reach, authentication failures, and
949protocol versions that do not agree.
950
951Each node line also shows `restoring`: the count of cold routes that hold
952an activation permit or wait for one (a capacity waiter already holds a
953permit, so each cold route counts once). During a rolling update, wait
954for every node to report `restoring=0` before you restart the next node,
955so one restart's cold work finishes before the next restart removes more
956warm capacity. A node that restarts recovers its previous session's log
957before it takes a lease. If a peer is already recovering that log, the
958node waits behind the peer while the peer's heartbeat is fresh, and it
959takes the recovery over only when the heartbeat stops.
960
961## List Durable Objects
962
963List the Durable Object instances in the bucket:
964
965```sh
966celld cell list \
967 --bucket "$CELLD_BUCKET" \
968 --endpoint "$S3_ENDPOINT" \
969 --region "$AWS_REGION"
970```
971
972Each line is a `Class:ID` cell scope. The ID is the Durable Object ID: a
97364-character hash unless the application supplies its own name. Give a
974class name to list only that class, and pass `--json` for one JSON object
975per line. The command puts the class in the storage prefix, so `--limit`
976applies only to that class. An instance appears after the first event reaches
977it, because its owner then writes an ownership record to the bucket. An ID
978that an application only derives does not appear.
979
980The listing also shows celld's own cells. A D1 database, a KV namespace,
981and a Workflow are each a cell in a reserved class, and their names start
982with `__`. They hold real data in the bucket, therefore the command shows
983them. The `--json` output marks each row with `"reserved": true` or
984`false`, so a script can select one kind:
985
986```sh
987celld cell list --all --json --bucket "$CELLD_BUCKET" |
988 jq -r 'select(.reserved | not) | .scope'
989```
990
991A storage request returns at most 1000 instances, so the command stops at
9921000 instances and writes this line to stderr:
993
994```
9951000 cells shown; more exist. Continue with --after Room:d99d9174b25e46310694dd931b47fbde70a7460bb7b210b546060651ea2ff6e0
996```
997
998Pass that `--after SCOPE` to read the next 1000 instances, or use
999`--limit N` for a different bound:
1000
1001```sh
1002celld cell list --bucket "$CELLD_BUCKET" \
1003 --after Room:d99d9174b25e46310694dd931b47fbde70a7460bb7b210b546060651ea2ff6e0
1004```
1005
1006Pass `--all` to read the whole listing in one command. This makes one
1007request for each 1000 instances, so it can take minutes on a large fleet;
1008the command reports its progress and its request count on stderr.
1009
1010The order is the storage order, and `--after` continues from the last
1011instance printed, so a sequence of `--after` commands lists each instance
1012one time. An instance that an application creates during the sequence can
1013appear or not appear, because the listing is not a snapshot.
1014
1015The command writes the instances to stdout and every message to stderr,
1016so a script reads only instance data:
1017
1018```sh
1019celld cell list --all --json --bucket "$CELLD_BUCKET" > cells.ndjson
1020```
1021
1022To see the superseded epoch prefixes that epoch GC can delete, run
1023`celld cell gc --dry-run`. The command takes the same listing options and
1024writes nothing. It prints one row for each cell that has candidates: the
1025candidate epochs, their bytes, and the base of the cell's restore chain.
1026The owners can delete later than the report shows, or not at all:
1027
1028- Only a fleet node with a positive `CELLD_LTX_RETENTION_SECS` deletes,
1029 and it uses that grace instead of `--grace-secs`.
1030- A paged cell waits until its local file is complete.
1031- An inactive cell waits until it is active again.
1032- A cell that is not paged waits until its activation has a write, so a
1033 cell that is only read deletes nothing. After the write, the owner
1034 compacts at its next pass and deletes at the pass after it. With
1035 `CELLD_LTX_COMPACTION=0`, the cell waits for a handoff snapshot.
1036- One pass deletes at most 64 epochs of a cell.
1037
1038If the command cannot read a cell, it reports the cell, continues, and
1039exits with an error at the end.
1040
1041```sh
1042celld cell gc --dry-run --bucket "$CELLD_BUCKET" --grace-secs 3600
1043```
1044
1045## Hot-cell overload
1046
1047celld admits a maximum of 64 concurrent fetch events for one Durable Object.
1048Set `CELLD_MAX_CELL_REQUESTS` to use a different positive limit.
1049
1050A Queue broker admits a maximum of 256 concurrent producer calls. It commits
1051at most 64 calls in one transaction, and four transactions can overlap their
1052durability proofs. These fixed bounds limit the copied message bodies while a
1053storage proof is slow.
1054
1055celld returns HTTP status `503` when the target reaches this limit, and it
1056does not start the excess event. The response contains `Retry-After: 1` and
1057`X-Celld-Overload: cell`, so the application can retry or reject the work.
1058A local or remote Queue owner uses the same status and headers when its
1059producer reservations are full. The Queue response body is
1060`{"error":"cell admission refused"}`. A fixed-rate client must count the
1061response as rejected work, so an immediate retry does not increase the
1062configured offered rate.
1063
1064A caught Queue producer error contains `cell overload: admission refused`, so
1065the Worker can return the same admission response to the client.
1066
1067The runtime writes a `cell_overload_refused` log event when a target becomes
1068saturated. The event contains the cell scope, the node, the region, the
1069in-flight count, and the limit. Count these overload responses separately
1070from the transport errors and the application failures.
1071
1072## Environment variables
1073
1074For the full list, run `celld -h`. This table shows the primary settings:
1075
1076| variable | purpose |
1077| --- | --- |
1078| `CELLD_BUCKET` | The fleet bucket, and an optional key prefix. The same as `--bucket` |
1079| `S3_ENDPOINT` | The S3-compatible endpoint. The same as `--endpoint` |
1080| `AWS_REGION`, `AWS_DEFAULT_REGION` | The storage region |
1081| `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_SESSION_TOKEN` | Explicit AWS credentials. The standard AWS credential chain is also available |
1082| `GOOGLE_APPLICATION_CREDENTIALS`, `GOOGLE_SERVICE_ACCOUNT_KEY` | Google credentials for a `gs://` bucket. Application Default Credentials are also available |
1083| `AZURE_STORAGE_ACCOUNT_NAME` | The storage account for an `az://` bucket. The bucket NAME is the container |
1084| `AZURE_STORAGE_ACCOUNT_KEY` | The storage account key. Do not combine it with an identity selector |
1085| `AZURE_AUTHORITY_HOST`, `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_FEDERATED_TOKEN_FILE` | The standard AKS workload identity environment for an `az://` bucket. The authority must be the public Azure host |
1086| `AZURE_STORAGE_USE_EMULATOR` | Set to `true` to develop against Azurite. celld does not qualify Azurite for a production fleet |
1087| `CELLD_ADDR` | The public Worker listener. The same as `--listen` |
1088| `CELLD_INTERNAL_ADDR` | The peer and operator listener. The same as `--internal-listen` |
1089| `CELLD_ADVERTISE` | The internal address that peers can reach. The same as `--advertise` |
1090| `CELLD_UNSAFE_PUBLIC_ADVERTISE` | Set to `1` to permit a literal public IP in `CELLD_ADVERTISE`. This setting does not resolve a DNS name or restrict the internal listener |
1091| `CELLD_NODE` | An explicit node-session ID. Use 1 to 128 ASCII letters, numbers, dots, dashes, or underscores. The value cannot be `.` or `..` |
1092| `CELLD_WATCH` | The local work directory for SQLite and replication |
1093| `CELLD_ESBUILD` | The path of the esbuild executable |
1094| `CELLD_ACTIVATIONS` | The limit for concurrent cold-cell activations (default: 8 for each available CPU, at least 16 and at most 128). A cold activation waits on the object store for most of its time, so the default is above the CPU count |
1095| `CELLD_DEPLOY_POLL_S` | The interval in seconds at which a node reads the deployment pointer and adopts a new deployment in place (default: 30) |
1096| `CELLD_DEPLOY_MAX_AGE_S` | How long a resident Durable Object can keep the previous deployment's code after an adoption before celld forces the move (default: 60; 0 forces at once) |
1097| `CELLD_OPERATION_DEADLINE_MS` | The deadline for a non-restore operation (default: 15000) |
1098| `CELLD_MAX_CELL_REQUESTS` | The concurrent fetch limit for one Durable Object or Queue broker (default: 64) |
1099| `CELLD_MAX_REQUEST_BODY_BYTES` | The body limit for a public Worker request or a direct Durable Object request (default: 1 GiB) |
1100| `CELLD_MAX_RESIDENT_CELLS` | The hard limit for resident cells, enforced at admission |
1101| `CELLD_IDLE_EVICT_S` | The age in seconds after which an idle resident cell leaves memory and hibernates (unset: only pressure or the residency cap removes an idle cell) |
1102| `CELLD_PLACEMENT_WEIGHT` | The ownership share of this node, relative to the other nodes' weights (default: the CPU count) |
1103| `CELLD_REBALANCE_INTERVAL_MS` | The interval between shared fleet sample reads and the maximum sample age, in milliseconds (default: 5000; 0 disables balancing) |
1104| `CELLD_MAX_RSS_MB` | The memory threshold for pressure shedding, applied to the greater of the allocator-adjusted RSS and the allocator-adjusted active cgroup working set (default: 80% of the available memory; 0 disables the threshold and the absolute cap) |
1105| `CELLD_DURABILITY` | How celld proves a write durable before it answers. The default is `fleet`: the node serving the cell sends the write to one or two other nodes and answers once they hold it on disk, or once the bucket upload finishes, whichever comes first. This needs two or more nodes; a single node has nobody to send to, so every write waits for the bucket. Set `bucket` to always wait for the bucket |
1106| `CELLD_LOG_PIPELINE` | The limit for fleet log rounds that can be in flight (default: 4) |
1107| `CELLD_LOG_HEDGE_MS` | The wait before a leader sends a second copy of a slow log append to a follower. The default is adaptive: celld derives the wait from the slowest recent append in the ensemble (4 times that append, at least 250 ms, and always below the eviction backstop), so a loaded fleet does not send copies for honest slow appends. Set a value to use a fixed wait in milliseconds, and set `0` to disable the second copy. An append is idempotent per sequence, so the copy is safe, and the leader uses the answer that arrives first and confirms |
1108| `CELLD_LTX_TRUNCATE_PAGES` | The WAL size, in pages, at which celld truncates an ordinary cell's WAL file at the next checkpoint (default: 128, a 512 KiB cap). A passive checkpoint does not shrink the WAL file, so each capture reads the stale region after a restart. The truncate keeps the read small. A truncate ends in a full image of the database, so a database larger than 4 MiB also waits until its WAL is larger than the database. Queue cells use passive checkpoints only. Set `0` to disable the truncate for all cells |
1109| `CELLD_LTX_RETENTION_SECS` | Unset or `0` by default, and then celld deletes no epoch prefix. A positive value enables epoch GC on a fleet node (`CELLD_DURABILITY=fleet`, the default); a node with `CELLD_DURABILITY=bucket` deletes nothing. After the owner of a cell activates it, the owner deletes each epoch prefix below the base of the cell's restore chain. The base is the epoch where a restore stops, because that epoch opens with a whole-database snapshot. A paged cell waits until its local file is complete, because until then it reads pages from the older epochs. A cell that is not paged waits until its activation has a write, so a cell that is only read deletes nothing. After the write, the owner compacts the new rows into the first L1 object of its epoch, even below `CELLD_LTX_COMPACTION_MIN_TXIDS`. That object lets the owner prove that a successor restores from its epoch. The owner compacts at its next pass after the write and deletes at the pass after the compaction, and each pass can come up to 5 minutes after the previous one. With `CELLD_LTX_COMPACTION=0` the owner does not compact, so the cell waits for a handoff snapshot. With `CELLD_LTX_HYDRATE_MBPS=0` a paged cell never completes its file, so epoch GC never runs for it. The owner keeps its own epoch and the epoch before it. It also keeps each epoch whose newest object is younger than the value, in seconds. The owner first writes `cells/<cell>/ltx/retired.json`, so that bundle GC and recovery treat the rows of those epochs as stored. Epoch GC skips facet streams. It needs a store with list-after-write consistency; see [the storage requirements](guarantees.md#what-the-bucket-must-provide). Run `celld cell gc --dry-run` to see the candidates |
1110| `CELLD_LTX_COMPACTION` | The default is `1`: celld creates additive L1 objects, and a takeover reads tens of objects instead of thousands. Set `0` on every node of a mixed fleet until all nodes can read v0.5.2 block objects, because an old reader cannot take over a cell after its first L1 publication |
1111| `CELLD_LTX_COMPACTION_MIN_TXIDS` | The durable TXID distance that queues a background L1 attempt (default: 256) |
1112| `CELLD_LTX_COMPACTION_MIN_MB` | The L0 bytes since the last fold that queue a background L1 attempt, in MiB (default: 32, at most 64). The byte threshold lets a cell with large rows compact before it reaches the transaction threshold |
1113| `CELLD_LTX_PAGED` | The default is `1`: celld restores a taken-over cell by paging when its chain is at least `CELLD_LTX_PAGED_MIN_MB`. It opens the database through a fault-in VFS that reads each page from the bucket on first use, instead of downloading the whole restore chain first, and a smaller chain is cloned. Set `0` to clone every chain. A paged cell's local file is a cache, so celld does not preserve it as an eviction snapshot and does not publish a handoff snapshot from it. A paged epoch continues the chain it paged in. celld uploads a small marker object at the next transaction before the cell serves, and its later objects follow it, so a restore composes the epochs. Set `0` on every node of a mixed fleet until all nodes run v0.4.1 or later, because a paged epoch holds no whole-database snapshot and a node before v0.4.1 restores one epoch only. Such a node refuses the activation of that cell, and the refusal is permanent for the cell. A full activation opens its epoch with a whole-database snapshot. A node pages only while every live lease in the fleet publishes a bucket format that reads a paged epoch, so a rolling update from a release without paged restore clones until that release has left the fleet; the `paged_gate` log event reports each change. A clean reload does not keep a paged cell resident; the next process pages it in again. An inspect of a paged cell must read the bucket, because celld does not copy the cell's sparse file in place. After the activation, celld fills the rest of the file in the background at `CELLD_LTX_HYDRATE_MBPS`, so a cell that stays resident soon reads only its local file. Until that fill completes, a read of a page that is not in the local file is a page fault. The fault reads the bucket synchronously inside the JavaScript turn, so it blocks the cell and the other cells on its isolate until its bucket reads complete. A query that reads many such pages can therefore take minutes. Set `CELLD_LTX_PAGED=0` to remove the fault path for every cell. A higher `CELLD_LTX_PAGED_MIN_MB` removes the fault path only for a chain that is smaller than the new value. In both cases, the cost is a slower activation, because celld downloads the whole chain before the cell serves |
1114| `CELLD_LTX_PAGED_MIN_MB` | The chain size, in MiB, from which a restore pages instead of cloning (default: 256). A clone of a smaller chain takes seconds and fits the node's memory, so it needs no fault path and no hydration. Set `0` to page every chain |
1115| `CELLD_LTX_HYDRATE_MBPS` | The rate, in MiB per second, at which a paged cell's file fills in the background (default: 16). One cell fills at a time per node. Set `0` to keep a paged cell sparse, so every cold page is read from the bucket on first use |
1116| `CELLD_LTX_COMPACTIONS` | The node-wide limit for concurrent background L1 attempts (default: 2). `CELLD_RELEASES` bounds final handoff snapshots |
1117| `CELLD_LTX_DURABILITY_TIMEOUT_SECS` | The budget for one durability proof, in seconds (default: 10). The budget runs from the moment the node starts to upload the write. A write that waits behind the uploads of other cells waits while the node proves other writes, for at most six budgets. The same budget bounds the final snapshot or L0 fallback of a handoff. A slow object store can need a longer budget for a large write |
1118| `CELLD_TOKIO_THREADS` | The worker thread count of the host Tokio runtime (default: the CPU count) |
1119| `RUST_LOG` | The runtime log filter |
1120
1121When a node starts, celld emits one `host_runtime` log event at the `info`
1122level. The `worker_count` field reports the worker count of the host Tokio
1123runtime, so an operator can verify the applied `CELLD_TOKIO_THREADS` setting.
1124
1125Each L1 compaction attempt merges at most 256 source objects. The buffer
1126budget for the source data is 64 MiB. If one source object exceeds this
1127budget, celld compacts that object through temporary files in the cell's
1128local LTX directory. The node must have free disk space for the source copy
1129and the output file. The codec keeps the page index in memory, so its memory
1130use increases with the page count. Compaction keeps the source objects and
1131publishes a continuous L1 range, including when a source overlaps an existing
1132L1 object.
1133
1134`CELLD_OUTPUT_GATE` is removed. Remove the variable from the environment,
1135including a value of `1` or an empty value. celld always waits for the
1136configured durability proof before it acknowledges a write.
1137
1138These settings are also removed. Remove them from the environment, including
1139an empty value or a value that matches the former default.
1140
1141| Removed setting | Current behavior |
1142| --- | --- |
1143| `CELLD_OTEL_SINK` | Set `CELLD_OTEL=1` for the fleet bucket or set `CELLD_OTEL` to the collector base URL for OTLP. |
1144| `CELLD_AI_BINDING`, `CELLD_AI_URL` | The experimental AI adapter is removed. Call the provider from application code and remove the AI binding declaration. |
1145| `CELLD_CLOUD_RESTART_ON_DEPLOY` | A managed deployment adopts the new code in place. Credential rotation can still restart the process. |
1146| `CELLD_STORAGE_PROBE` | A node checks the storage contract before it serves a bucket-backed deployment. |
1147| `CELLD_EVICTIONS` | A node runs at most four concurrent evictions. |
1148| `CELLD_LOG_CAPTURE_WORKERS` | A node uses at most eight workers for log capture. |
1149| `CELLD_REBALANCE_BATCH_CELLS` | A balancing batch moves at most 32 idle cells. The release limit and the receiver capacity can reduce this count. |
1150| `CELLD_PRESENCE_SHADOW` | A managed node sends its serving status and its owned-cell count. It does not send a separate bucket comparison. |
1151| `CELLD_LOG_BUNDLE` | Fleet durability uses bundled tiering. A node still uses per-cell uploads when the bucket must prove a write. |
1152| `CELLD_QUEUE_PRODUCER_GROUP_MS` | A Queue owner uses a 4 ms timer to group concurrent producer calls into a SQLite transaction. |
1153| `CELLD_LOG_GROUP_COMMIT_MS` | A node waits 1 ms before a fleet log capture when Queue writes are pending. |
1154| `CELLD_PACED_HANDOFF` | A bucket-backed node attempts ownership handoff within the shutdown budget. Set `CELLD_SHUTDOWN_TOTAL_MS` to match the supervisor grace. |
1155
1156The Queue batching timers do not set a response deadline. A Queue still waits
1157for the wake-entry proof and the configured write durability proof.
1158
1159Fleet uploads combine changes from multiple cells into shared bucket objects.
1160`CELLD_DURABILITY=bucket` still requires a bucket proof for every acknowledged
1161write, even when peers are available. Recovery can read the existing bundles
1162and the per-cell objects.
1163
1164The storage check still distinguishes a contract violation from an ambiguous
1165transport error. A violation prevents startup. After the existing retries,
1166an ambiguous error produces a warning and permits startup.
1167
1168Use `celld diagnose --read-only` to check the bucket leases and the peers.
1169A managed presence report does not prove that a node holds a bucket lease.
1170
1171The help output also shows the advanced tuning switches and their
1172defaults.
1173
1174An unset variable selects its documented default. A Boolean variable
1175accepts only `0` or `1`. celld exits during startup when a supplied value
1176is invalid.