| 1 | # celld |
| 2 | |
| 3 | celld is a stateful distributed system. It runs server-side JavaScript on |
| 4 | your machines, and it stores the long-term state in a bucket that you own: |
| 5 | S3-compatible, Google Cloud Storage, or Azure Blob Storage. The JavaScript |
| 6 | API and the configuration follow Cloudflare Workers: Workers, Durable |
| 7 | Objects, KV, Queues, D1, R2, Workflows, Cron Triggers, and static assets. |
| 8 | |
| 9 | ## Cells and nodes |
| 10 | |
| 11 | In Cloudflare terms, a cell is a Durable Object: a small server with a |
| 12 | name and a private SQLite database. You make one cell for each user, |
| 13 | document, chat room, or AI agent. A cell serves HTTP, holds WebSocket |
| 14 | connections, sets alarms, and makes outbound connections. Cells share no |
| 15 | database. Each cell runs on one thread: a second request interleaves only |
| 16 | while the first awaits, and storage operations are synchronous. |
| 17 | |
| 18 | You run celld as one process on each machine. That process is a **node**, |
| 19 | and the nodes that share one bucket are a **fleet**. Any node can serve |
| 20 | any cell, so you add capacity by starting another node against the same |
| 21 | bucket. |
| 22 | |
| 23 | ## Cell lifecycle |
| 24 | |
| 25 | A cell has the same states as a Durable Object. A **resident** cell is in |
| 26 | memory: it is **active** while it does work, and **idle** when it waits. |
| 27 | celld removes an idle cell from memory after `CELLD_IDLE_EVICT_S` seconds |
| 28 | without work, and earlier under memory pressure or at the residency cap. |
| 29 | Without `CELLD_IDLE_EVICT_S`, only pressure or the cap removes an idle |
| 30 | cell. 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 |
| 32 | object in the bucket and costs almost zero. Every cell starts inactive. |
| 33 | |
| 34 | The constructor runs again on each activation, because a cell keeps no |
| 35 | memory across these transitions. A hibernated cell wakes like a cold start, |
| 36 | but its WebSocket clients stay connected and it stays on its node. |
| 37 | |
| 38 | Each activation can add a new epoch prefix to the bucket. celld deletes |
| 39 | the older prefixes only when `CELLD_LTX_RETENTION_SECS` enables epoch GC, |
| 40 | so without it the bytes of a cell increase with each activation. See |
| 41 | [epoch GC](guarantees.md#epoch-gc). |
| 42 | |
| 43 | One 8 GB node holds 1,000 resident cells, so one resident cell costs |
| 44 | approximately $0.05 each month. |
| 45 | |
| 46 | ## Ownership and durability |
| 47 | |
| 48 | Exactly one node serves a cell at a time. A node claims a cell with a |
| 49 | conditional write of a small record to the bucket, so the bucket decides |
| 50 | who wins. There is no leader election and no membership list. The claim |
| 51 | expires unless the node renews it, so a failed machine releases its cells. |
| 52 | |
| 53 | celld 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 | |
| 62 | A single node has no peer, so a one-node fleet in `fleet` mode waits for the |
| 63 | bucket on every write, as `bucket` mode does. Two or more |
| 64 | nodes are faster, because a follower fsync is much faster than an object |
| 65 | store write. Run two or more nodes if write latency |
| 66 | matters. A fleet that loses all but one node falls back to the bucket in the |
| 67 | same way, and it stays correct. Set `bucket` to wait for the bucket on every |
| 68 | write, even when peers are available. |
| 69 | |
| 70 | When a node stops, another node takes its cells over, and first collects |
| 71 | the data that the stopped node had not uploaded. See |
| 72 | [what celld guarantees](guarantees.md) for the mechanism and the bucket |
| 73 | requirements. |
| 74 | |
| 75 | ## Alarms |
| 76 | |
| 77 | When an event sets an alarm before its response boundary, celld does not |
| 78 | send a successful response until a durable wake entry covers the alarm. A |
| 79 | later `waitUntil` alarm does not delay the response of another event. |
| 80 | |
| 81 | A hibernated cell fires its alarm on the node that owns it. One node holds |
| 82 | the 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 | |
| 127 | Each service page contains a runnable example and the known differences from |
| 128 | the 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 |
| 146 | curl -fsSL https://celld.dev/install.sh | sh |
| 147 | ``` |
| 148 | |
| 149 | The installer downloads the `celld` binary. Replication runs inside the |
| 150 | process, so a node needs no external replicator. If the installer tells |
| 151 | you, 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 |
| 153 | installer again with the previous tag. Each |
| 154 | [release](https://github.com/denoland/celld/releases) has a build |
| 155 | attestation: verify a file with |
| 156 | `gh attestation verify <asset> --repo denoland/celld`. |
| 157 | |
| 158 | ## Configure object storage |
| 159 | |
| 160 | The `s3://`, `gs://`, and `az://` scheme names are case-insensitive, and |
| 161 | celld ignores leading and trailing whitespace in `CELLD_BUCKET`. |
| 162 | |
| 163 | For an S3-compatible bucket, celld uses the standard AWS credential chain, |
| 164 | including an EC2 instance role and Amazon EKS Pod Identity. For Cloudflare |
| 165 | R2, create a bucket and an S3 API token with access to it, and set: |
| 166 | |
| 167 | ```sh |
| 168 | export AWS_ACCESS_KEY_ID=... |
| 169 | export AWS_SECRET_ACCESS_KEY=... |
| 170 | export AWS_REGION=auto |
| 171 | export S3_ENDPOINT=https://ACCOUNT_ID.r2.cloudflarestorage.com |
| 172 | export CELLD_BUCKET=s3://YOUR-BUCKET |
| 173 | ``` |
| 174 | |
| 175 | For 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 |
| 179 | scope permits only storage reads, so create the instance with the |
| 180 | `cloud-platform` scope. |
| 181 | |
| 182 | For Azure Blob Storage, the bucket name is the container: |
| 183 | |
| 184 | ```sh |
| 185 | export AZURE_STORAGE_ACCOUNT_NAME=YOUR-ACCOUNT |
| 186 | export AZURE_STORAGE_ACCOUNT_KEY=... |
| 187 | export CELLD_BUCKET=az://YOUR-CONTAINER |
| 188 | ``` |
| 189 | |
| 190 | You must configure exactly one Azure credential family: an account key, a |
| 191 | managed identity, or a workload identity. A system-assigned managed |
| 192 | identity needs only the account name. A user-assigned managed identity |
| 193 | needs 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) |
| 196 | role or equal permissions. A managed identity works on an Azure VM and an |
| 197 | AKS node, but not on App Service or Container Apps; use a workload |
| 198 | identity 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 |
| 202 | Azure configuration variable, such as another credential source or an |
| 203 | endpoint override. For local development against Azurite, set |
| 204 | `AZURE_STORAGE_USE_EMULATOR=true`. celld does not qualify Azurite for a |
| 205 | fleet. |
| 206 | |
| 207 | A `gs://` or `az://` bucket takes no `S3_ENDPOINT` and no `AWS_*` |
| 208 | credentials, and celld ignores the storage region. |
| 209 | |
| 210 | The bucket credentials give full control of the fleet, so keep them safe. |
| 211 | |
| 212 | A bucket value can add a key prefix, `s3://YOUR-BUCKET/PREFIX`, so two |
| 213 | fleets can share one bucket. Without a prefix, the objects stay at the |
| 214 | bucket root. |
| 215 | |
| 216 | The store must provide conditional writes, exact ranged reads, and |
| 217 | read-after-write consistency. Amazon S3, Cloudflare R2, Google Cloud |
| 218 | Storage, Tigris, and Azure Blob Storage qualify; Backblaze B2, Hetzner, |
| 219 | and DigitalOcean Spaces do not. MinIO (community edition) passes the |
| 220 | storage test but is not qualified for production; do not use |
| 221 | RELEASE.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 | |
| 226 | Install `esbuild` on `PATH` if the project contains Worker code. Then run |
| 227 | `celld deploy` in a Wrangler project: |
| 228 | |
| 229 | ```sh |
| 230 | git clone https://github.com/denoland/celld |
| 231 | cd celld/examples/counter |
| 232 | celld 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 |
| 239 | bindings, variables, cron triggers, D1 databases, KV namespaces, Queues, |
| 240 | R2 buckets, Workflows, WebAssembly modules, and static assets. An unknown |
| 241 | Wrangler configuration key stops the deploy. See |
| 242 | [Cloudflare compatibility](cloudflare-compat.md) for the complete boundary. |
| 243 | A node verifies the SHA-256 digest of each module before it builds a |
| 244 | deployment. |
| 245 | |
| 246 | A 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 |
| 248 | adopts a new deployment in place. `POST /reload` on the internal listener |
| 249 | adopts it now, and also rebuilds an unchanged deployment. A request that |
| 250 | started on the previous deployment finishes on it. A deployment that does |
| 251 | not build leaves the current one serving, and the node reports the error |
| 252 | in its log and in the `/reload` response. |
| 253 | |
| 254 | An inactive Durable Object runs the new deployment at its next activation. |
| 255 | A resident one moves when no request, alarm handler, or regular WebSocket |
| 256 | is active, and it keeps its storage and its hibernatable WebSockets. A |
| 257 | request that arrives during the move waits for the new code. An outbound |
| 258 | call from a request that already runs in the object does not wait, so that |
| 259 | request can finish on the old code. After |
| 260 | `CELLD_DEPLOY_MAX_AGE_S` seconds (default 60; 0 forces at once), celld |
| 261 | forces the move: it cancels the running work and closes regular WebSockets |
| 262 | with code 1012, as Cloudflare does. During the move, a request on one |
| 263 | deployment can call a Durable Object on the other, so two adjacent |
| 264 | versions must accept each other's calls. `/state` reports the deployment |
| 265 | of each resident object. |
| 266 | |
| 267 | ## Develop an application locally |
| 268 | |
| 269 | ```sh |
| 270 | celld dev [PROJECT_DIR_OR_CONFIG] |
| 271 | ``` |
| 272 | |
| 273 | The command starts a local object store, deploys the application, and runs |
| 274 | one node. It does not need Docker or a cloud bucket. The Worker listener |
| 275 | is `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 | |
| 286 | Set `NO_COLOR` to disable color, or `FORCE_COLOR` to enable it when the |
| 287 | output is not a terminal. `NO_COLOR` takes priority. |
| 288 | |
| 289 | The 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 |
| 292 | Worker variable and overrides `vars`. A line can start with `export`, and |
| 293 | a quoted value can span lines, for example a PEM key. Comments after a |
| 294 | value and variable references are not supported. In `.env` files, the |
| 295 | command skips, with a warning, an entry that is not a valid binding name |
| 296 | or that collides with another binding; in `.dev.vars` such an entry stops |
| 297 | the build. `celld deploy` does not read these files. Add `.dev.vars`, |
| 298 | `.env`, `.env.local`, and `.celld/` to `.gitignore`. |
| 299 | |
| 300 | The command keeps the local state in `.celld/dev`, across restarts and |
| 301 | configuration changes. celld does not migrate stored state, so a stored |
| 302 | value from an earlier configuration can make the application fail with an |
| 303 | error that looks unrelated. Use `--clean` to start from an empty state. |
| 304 | `--clean` deletes nothing else under `.celld`. |
| 305 | |
| 306 | The command watches the project directory and rebuilds on a source, |
| 307 | configuration, or dotenv change. The current application serves during the |
| 308 | build, and a failed build does not replace it. The watcher ignores |
| 309 | `.celld`, `.git`, `.wrangler`, `node_modules`, and `target` at each depth, |
| 310 | and it does not watch files outside the project. |
| 311 | |
| 312 | The local object store is not available to a fleet node or an operator |
| 313 | subcommand; they need a supported cloud bucket. |
| 314 | |
| 315 | ## Operate D1, KV, and R2 |
| 316 | |
| 317 | These commands use the fleet bucket. `celld d1` and `celld kv` reach the |
| 318 | database cell through a node. |
| 319 | |
| 320 | ```sh |
| 321 | celld d1 migrations apply ledger --bucket "$CELLD_BUCKET" |
| 322 | celld kv bulk put sessions wrangler-export.json --bucket "$CELLD_BUCKET" |
| 323 | ``` |
| 324 | |
| 325 | The `migrations_dir` value must be a relative path inside the project, |
| 326 | without a `..` component. The KV bulk commands use the Wrangler file |
| 327 | format. `celld kv bulk get` streams; a named output file changes only |
| 328 | after the export completes, and a failed stdout export leaves an |
| 329 | incomplete JSON array. |
| 330 | |
| 331 | `celld r2` reads and writes the objects of an `r2_buckets` binding under |
| 332 | the reserved `r2/<bucket_name>/` prefix. It needs no running node, so a |
| 333 | release pipeline can publish an artifact before it deploys. |
| 334 | |
| 335 | ```sh |
| 336 | celld 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 | |
| 342 | The first argument is the `bucket_name`, not the binding name. `--metadata` |
| 343 | becomes `customMetadata`, and the content flags become `httpMetadata`. An |
| 344 | object 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 |
| 351 | key and `--json` for one JSON object per key. |
| 352 | |
| 353 | Every celld command writes data to stdout and messages to stderr. A closed |
| 354 | stdout pipe is a successful stop. |
| 355 | |
| 356 | ## Start a node |
| 357 | |
| 358 | For local development, the default listener is sufficient: |
| 359 | |
| 360 | ```sh |
| 361 | celld \ |
| 362 | --bucket "$CELLD_BUCKET" \ |
| 363 | --endpoint "$S3_ENDPOINT" \ |
| 364 | --region "$AWS_REGION" |
| 365 | ``` |
| 366 | |
| 367 | For a fleet node, bind the public and internal listeners separately: |
| 368 | |
| 369 | ```sh |
| 370 | celld \ |
| 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 |
| 380 | non-loopback `--listen`. You must route the advertised address to the |
| 381 | internal listener, not to the public listener; celld cannot verify this. |
| 382 | |
| 383 | ## Add nodes |
| 384 | |
| 385 | Start each node with the same bucket settings and its own reachable |
| 386 | `--advertise` address. The nodes find each other through leases in the |
| 387 | bucket; there is no join command. |
| 388 | |
| 389 | Peer traffic has no TLS and cell fetch and RPC traffic is not signed, and |
| 390 | the internal listener has an unauthenticated operator API. Put the |
| 391 | advertised addresses on a trusted private network or an encrypted overlay |
| 392 | such as WireGuard or Tailscale, and never expose the internal listener to |
| 393 | the internet. See [security](security.md). |
| 394 | |
| 395 | The node that receives a request activates a new cell, so a load balancer |
| 396 | must include a new node in its rotation. A node at its residency cap or |
| 397 | under memory pressure hands the activation to the least-loaded peer. A |
| 398 | pressure eviction releases the ownership record |
| 399 | (`CELLD_PRESSURE_OWNERSHIP=release`, the default), so the cell can move. |
| 400 | An idle eviction keeps the record, so the cell wakes on its own node. An |
| 401 | idle eviction must stop the runtime within `CELLD_OPERATION_DEADLINE_MS`, |
| 402 | or the cell stays resident until the next idle period. |
| 403 | |
| 404 | A new node also receives idle cells. Every node reads a shared fleet |
| 405 | sample, `fleet/capacity-v1.json`, every `CELLD_REBALANCE_INTERVAL_MS` |
| 406 | (default 5000; `0` disables balancing). Each node gets a share of the |
| 407 | owned cells in proportion to `CELLD_PLACEMENT_WEIGHT` (default: the CPU |
| 408 | count). The most loaded node hands at most 32 idle cells at a time to the |
| 409 | node furthest below its target, and a receiver fills to 2% below its |
| 410 | target. Only a hibernated cell moves; its hibernatable WebSockets close |
| 411 | with code 1012 so that the clients reconnect. A fleet without |
| 412 | `CELLD_IDLE_EVICT_S` therefore balances only the cells that hibernate on |
| 413 | their 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 |
| 415 | without 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 | |
| 421 | celld does not scale itself. An external system starts and stops the |
| 422 | nodes, and celld hands the cells off. |
| 423 | |
| 424 | Each node writes its lease to `nodes/<node>.json` in the bucket. The lease |
| 425 | lives `CELLD_TTL_MS` (default 10000) and renews at one third of that. Its |
| 426 | load 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 |
| 430 | dormant cells; a restarted node omits it until it has read its ownership |
| 431 | records. `resident_cells` counts only cells in memory. The memory and CPU |
| 432 | values 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 | |
| 448 | A `live_empty` count that persists for more than 30 seconds means that |
| 449 | isolate maintenance does not run. A persistent `retiring` count means that |
| 450 | a turn or a request still holds the heap. |
| 451 | |
| 452 | A positive `capacity_waiting` or a `pressured` lease is the signal to add |
| 453 | a node. Scale down only when every remaining node reports |
| 454 | `memory_headroom` and a small `restoring` backlog. A drain into a full |
| 455 | fleet leaves the cells dormant on the survivors, and each later activation |
| 456 | must shed a resident cell. |
| 457 | |
| 458 | `/.well-known/celld/health` on the public listener is a boolean. It |
| 459 | reports 503 during a drain and before a joining node settles. |
| 460 | |
| 461 | ## Shut down and roll out a node |
| 462 | |
| 463 | celld shuts down gracefully on SIGTERM or SIGINT. The health path reports |
| 464 | 503, new public requests receive 503 with the connection closed, and |
| 465 | accepted requests finish. The node hands its cells off in batches: it |
| 466 | cancels running alarms (the successor retries them), proves the data |
| 467 | durable, publishes a final snapshot, and releases each ownership record to |
| 468 | a peer. The peer keeps the cell dormant until a request arrives. A |
| 469 | database larger than the durability deadline can upload (80 MiB at the |
| 470 | default 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 | |
| 480 | You must set the orchestrator stop grace (systemd `TimeoutStopSec`, |
| 481 | Kubernetes `terminationGracePeriodSeconds`) above |
| 482 | `CELLD_SHUTDOWN_TOTAL_MS`, or SIGKILL can interrupt the handoff. celld |
| 483 | rejects the removed `CELLD_SHUTDOWN_DRAIN_MS` and |
| 484 | `CELLD_DRAIN_TOKEN_WAIT_MS` at startup. |
| 485 | |
| 486 | Concurrent stops do not flood the survivors: a draining node claims a |
| 487 | fleet drain token, so nodes hand off one at a time. A node that cannot |
| 488 | claim the token within its wait proceeds without it. |
| 489 | |
| 490 | A new process does not report healthy until the fleet settles: no node |
| 491 | drains, every node is below its memory low watermark, the restore backlogs |
| 492 | are small, and ownership is balanced. At `CELLD_READY_FLEET_GATE_MS`, |
| 493 | celld logs `ready_gate_expired` once, but readiness stays closed, so set |
| 494 | an orchestrator rollout deadline. After the first healthy response, fleet |
| 495 | state does not remove readiness. |
| 496 | |
| 497 | A cut handoff can leave the log of the stopped process for its |
| 498 | replacement to recover. Another process can replace a recovery that does |
| 499 | not respond for 30 seconds. |
| 500 | |
| 501 | A remote call to a cell that is changing owner waits for the new owner, |
| 502 | for at most `CELLD_OPERATION_DEADLINE_MS` (default 15000). celld retries |
| 503 | only an attempt that provably did not start. An application must keep one |
| 504 | stable operation ID when it retries an ambiguous fetch, RPC, D1, or |
| 505 | service operation. A WebSocket client must reconnect. |
| 506 | |
| 507 | To roll out a new version, use the rolling update of your orchestrator: |
| 508 | stop each node with SIGTERM, wait for its replacement to report healthy, |
| 509 | and then move to the next node. celld paces the handoffs and readiness |
| 510 | itself. |
| 511 | |
| 512 | `POST /shutdown?handoff=preserve` prepares a same-node restart that keeps |
| 513 | the ownership records. It cancels cold activations and uploads each |
| 514 | stopped database first. If an upload fails, the next process uses normal |
| 515 | recovery. The internal operator API is alpha and can change in any |
| 516 | release, 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 | |
| 546 | ## Diagnose a fleet |
| 547 | |
| 548 | `celld diagnose` reads the node leases and probes each live peer. It does |
| 549 | not take a lease or change ownership. Use `--peer NODE_ID`, repeatable, to |
| 550 | probe only some nodes. |
| 551 | |
| 552 | ```sh |
| 553 | celld diagnose \ |
| 554 | --bucket "$CELLD_BUCKET" \ |
| 555 | --endpoint "$S3_ENDPOINT" \ |
| 556 | --region "$AWS_REGION" |
| 557 | ``` |
| 558 | |
| 559 | The report shows expired leases, bad advertised addresses, unreachable |
| 560 | peers, authentication failures, and protocol mismatches. Each node line |
| 561 | shows `restoring`, the cold activations in progress. During a rolling |
| 562 | update, wait for `restoring=0` on every node before you restart the next. |
| 563 | |
| 564 | ## List Durable Objects |
| 565 | |
| 566 | ```sh |
| 567 | celld cell list \ |
| 568 | --bucket "$CELLD_BUCKET" \ |
| 569 | --endpoint "$S3_ENDPOINT" \ |
| 570 | --region "$AWS_REGION" |
| 571 | ``` |
| 572 | |
| 573 | Each line is a `Class:ID` scope. Give a class name to list only that |
| 574 | class, and pass `--json` for one JSON object per line. An instance appears |
| 575 | after its first event; an ID that is only derived does not appear. D1 |
| 576 | databases, KV namespaces, and Workflows are cells in reserved classes whose |
| 577 | names start with `__`. The `--json` output marks them `"reserved": true`: |
| 578 | |
| 579 | ```sh |
| 580 | celld cell list --all --json --bucket "$CELLD_BUCKET" | |
| 581 | jq -r 'select(.reserved | not) | .scope' |
| 582 | ``` |
| 583 | |
| 584 | The command stops at 1000 instances and prints the continuation on stderr: |
| 585 | |
| 586 | ``` |
| 587 | 1000 cells shown; more exist. Continue with --after Room:d99d9174b25e46310694dd931b47fbde70a7460bb7b210b546060651ea2ff6e0 |
| 588 | ``` |
| 589 | |
| 590 | Pass that `--after SCOPE` for the next page, `--limit N` for a different |
| 591 | page size, or `--all` for everything (one request per 1000, with progress |
| 592 | on stderr). The listing is not a snapshot, but a sequence of `--after` |
| 593 | commands lists each existing instance once. |
| 594 | |
| 595 | `celld cell gc --dry-run` takes the same options and prints, for each cell, |
| 596 | the epoch prefixes that epoch GC can delete, their bytes, and the restore |
| 597 | base. It writes nothing, and it exits with an error at the end if it could |
| 598 | not read a cell. |
| 599 | |
| 600 | ```sh |
| 601 | celld cell gc --dry-run --bucket "$CELLD_BUCKET" --grace-secs 3600 |
| 602 | ``` |
| 603 | |
| 604 | The real deletion can come later or not at all. Only a node with a |
| 605 | positive `CELLD_LTX_RETENTION_SECS` deletes, with that grace instead of |
| 606 | `--grace-secs`. A cell deletes only while it is active, after its |
| 607 | activation has a write and, if paged, after its local file is complete. |
| 608 | With `CELLD_LTX_COMPACTION=0`, a cell on a fleet node waits for a handoff |
| 609 | snapshot. One pass deletes at most 64 epochs of a cell. |
| 610 | |
| 611 | ## Hot-cell overload |
| 612 | |
| 613 | celld admits at most 64 concurrent fetch events for one Durable Object |
| 614 | (`CELLD_MAX_CELL_REQUESTS`). A Queue broker admits 256 concurrent producer |
| 615 | calls, commits at most 64 in one transaction, and overlaps up to four |
| 616 | transactions. |
| 617 | |
| 618 | Over the limit, celld returns `503` with `Retry-After: 1` and |
| 619 | `X-Celld-Overload: cell`, and does not start the event. The Queue response |
| 620 | body is `{"error":"cell admission refused"}`, and a caught Queue producer |
| 621 | error contains `cell overload: admission refused`. A load generator must |
| 622 | count these responses as rejected work. celld logs `cell_overload_refused` |
| 623 | with the cell scope, node, region, in-flight count, and limit. |
| 624 | |
| 625 | ## Environment variables |
| 626 | |
| 627 | For the full list, including advanced tuning switches, run `celld -h`. An |
| 628 | unset variable selects its default. A Boolean variable accepts only `0` or |
| 629 | `1`. celld exits at startup on an invalid value. |
| 630 | |
| 631 | | variable | purpose | |
| 632 | | --- | --- | |
| 633 | | `CELLD_BUCKET` | The fleet bucket, and an optional key prefix. The same as `--bucket` | |
| 634 | | `S3_ENDPOINT` | The S3-compatible endpoint. The same as `--endpoint` | |
| 635 | | `AWS_REGION`, `AWS_DEFAULT_REGION` | The storage region | |
| 636 | | `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_SESSION_TOKEN` | Explicit AWS credentials. The standard AWS credential chain is also available | |
| 637 | | `GOOGLE_APPLICATION_CREDENTIALS`, `GOOGLE_SERVICE_ACCOUNT_KEY` | Google credentials for a `gs://` bucket. Application Default Credentials are also available | |
| 638 | | `AZURE_STORAGE_ACCOUNT_NAME` | The storage account for an `az://` bucket | |
| 639 | | `AZURE_STORAGE_ACCOUNT_KEY` | The storage account key. Do not combine it with an identity selector | |
| 640 | | `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 | |
| 641 | | `AZURE_STORAGE_USE_EMULATOR` | Set to `true` to develop against Azurite | |
| 642 | | `CELLD_ADDR` | The public Worker listener. The same as `--listen` | |
| 643 | | `CELLD_INTERNAL_ADDR` | The peer and operator listener. The same as `--internal-listen` | |
| 644 | | `CELLD_ADVERTISE` | The internal address that peers can reach. The same as `--advertise` | |
| 645 | | `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 | |
| 646 | | `CELLD_NODE` | An explicit node-session ID: 1 to 128 ASCII letters, numbers, dots, dashes, or underscores, but not `.` or `..` | |
| 647 | | `CELLD_WATCH` | The local work directory for SQLite and replication | |
| 648 | | `CELLD_ESBUILD` | The path of the esbuild executable | |
| 649 | | `CELLD_ACTIVATIONS` | Concurrent cold-cell activations (default: 8 per CPU, at least 16, at most 128) | |
| 650 | | `CELLD_DEPLOY_POLL_S` | The deployment pointer poll interval in seconds (default: 30) | |
| 651 | | `CELLD_DEPLOY_MAX_AGE_S` | Seconds before celld forces a resident Durable Object onto a new deployment (default: 60; 0 forces at once) | |
| 652 | | `CELLD_OPERATION_DEADLINE_MS` | The deadline for a non-restore operation (default: 15000) | |
| 653 | | `CELLD_MAX_CELL_REQUESTS` | Concurrent fetch events for one Durable Object (default: 64) | |
| 654 | | `CELLD_MAX_REQUEST_BODY_BYTES` | The body limit for a public Worker request or a direct Durable Object request (default: 1 GiB) | |
| 655 | | `CELLD_MAX_RESIDENT_CELLS` | The hard limit for resident cells, enforced at admission | |
| 656 | | `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) | |
| 657 | | `CELLD_PLACEMENT_WEIGHT` | The ownership share of this node, relative to the other nodes (default: the CPU count) | |
| 658 | | `CELLD_REBALANCE_INTERVAL_MS` | The fleet sample interval and maximum age (default: 5000; 0 disables balancing) | |
| 659 | | `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) | |
| 660 | | `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 | |
| 661 | | `CELLD_LOG_PIPELINE` | Fleet log rounds in flight (default: 4) | |
| 662 | | `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 | |
| 663 | | `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 | |
| 664 | | `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) | |
| 665 | | `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 | |
| 666 | | `CELLD_LTX_COMPACTION_MIN_TXIDS` | The TXID distance that queues an L1 compaction (default: 256) | |
| 667 | | `CELLD_LTX_COMPACTION_MIN_MB` | The L0 MiB that queue an L1 compaction (default: 32, at most 64) | |
| 668 | | `CELLD_LTX_COMPACTIONS` | Concurrent L1 compactions per node (default: 2) | |
| 669 | | `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 | |
| 670 | | `CELLD_LTX_PAGED_MIN_MB` | The chain size, in MiB, from which a restore pages (default: 256; `0` pages every chain) | |
| 671 | | `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) | |
| 672 | | `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 | |
| 673 | | `CELLD_TOKIO_THREADS` | Host Tokio worker threads (default: the CPU count). The `host_runtime` log event at startup reports `worker_count` | |
| 674 | | `RUST_LOG` | The runtime log filter | |
| 675 | |
| 676 | An L1 compaction merges at most 256 source objects within a 64 MiB buffer. |
| 677 | A larger source object spills to temporary files in the cell's local LTX |
| 678 | directory, so the node needs free disk for the source and the output. |
| 679 | |
| 680 | These settings are removed. Remove them from the environment, including an |
| 681 | empty value or the former default: |
| 682 | |
| 683 | | removed setting | current behavior | |
| 684 | | --- | --- | |
| 685 | | `CELLD_OUTPUT_GATE` | celld always waits for the durability proof before it acknowledges a write | |
| 686 | | `CELLD_SHUTDOWN_DRAIN_MS`, `CELLD_DRAIN_TOKEN_WAIT_MS` | Rejected at startup. Use `CELLD_SHUTDOWN_TOTAL_MS` | |
| 687 | | `CELLD_OTEL_SINK` | Set `CELLD_OTEL=1` for the fleet bucket or set `CELLD_OTEL` to the collector base URL for OTLP | |
| 688 | | `CELLD_AI_BINDING`, `CELLD_AI_URL` | The AI adapter is removed. Call the provider from application code and remove the AI binding | |
| 689 | | `CELLD_CLOUD_RESTART_ON_DEPLOY` | A managed deployment adopts the new code in place. Credential rotation can still restart the process | |
| 690 | | `CELLD_STORAGE_PROBE` | A node always checks the storage contract. A violation prevents startup; an ambiguous transport error produces a warning | |
| 691 | | `CELLD_EVICTIONS` | A node runs at most four concurrent evictions | |
| 692 | | `CELLD_LOG_CAPTURE_WORKERS` | A node uses at most eight log capture workers | |
| 693 | | `CELLD_REBALANCE_BATCH_CELLS` | A balancing batch moves at most 32 idle cells | |
| 694 | | `CELLD_PRESENCE_SHADOW` | A managed node sends its serving status and owned-cell count. Use `celld diagnose --read-only` to check leases | |
| 695 | | `CELLD_LOG_BUNDLE` | Fleet durability always bundles uploads | |
| 696 | | `CELLD_QUEUE_PRODUCER_GROUP_MS` | A Queue owner groups producer calls with a 4 ms timer | |
| 697 | | `CELLD_LOG_GROUP_COMMIT_MS` | A node waits 1 ms before a fleet log capture when Queue writes are pending | |
| 698 | | `CELLD_PACED_HANDOFF` | A node always attempts the handoff within `CELLD_SHUTDOWN_TOTAL_MS` | |