| 1 | # celld documentation |
| 2 | |
| 3 | celld is a stateful distributed system. It runs server-side JavaScript on |
| 4 | your machines. It keeps all shared data in an S3-compatible or Google |
| 5 | Cloud Storage bucket that you own. The JavaScript API is the same API |
| 6 | that Cloudflare Workers and Durable Objects supply. |
| 7 | |
| 8 | In Cloudflare terms, a cell is a Durable Object: a small server with a |
| 9 | name and a private SQLite database. You make one cell for each user, each |
| 10 | document, each chat room, or each AI agent. A cell serves HTTP, holds |
| 11 | WebSocket connections, sets alarms, and makes outbound connections. Each |
| 12 | cell runs on one thread, so two requests to the same cell never run at |
| 13 | the same instant. A second request can interleave only while the first |
| 14 | awaits, and storage operations are synchronous, so a storage operation |
| 15 | never interleaves at all. The data in a cell therefore stays consistent. |
| 16 | Cells share no database, and the application divides into cells from the |
| 17 | start. |
| 18 | |
| 19 | A cell has the same states as a Durable Object. A **resident** cell is in |
| 20 | memory: it is **active** while it does work, and **idle** when it waits. |
| 21 | celld removes an idle cell from memory. A cell that then keeps its |
| 22 | hibernatable WebSocket clients, and stays on its node, is **hibernated**. |
| 23 | A cell that no node holds is **inactive**. An inactive cell is only an |
| 24 | object in the bucket, so it costs almost zero, and every cell starts in |
| 25 | this state. |
| 26 | |
| 27 | Memory holds nothing across these transitions, so the constructor runs |
| 28 | again on the next event. A hibernated cell therefore starts as a cold |
| 29 | start does, and only two facts separate the two states: the WebSocket |
| 30 | clients stay connected, and the cell stays on its node. |
| 31 | |
| 32 | One 8 GB node holds 1,000 resident cells, so one resident cell costs |
| 33 | approximately $0.05 each month. |
| 34 | |
| 35 | The bucket is the coordinator. There is no membership protocol, no |
| 36 | failure detector, and no consensus service. One atomic write to the |
| 37 | bucket gives a node the ownership of a cell. Replication sends the SQLite |
| 38 | data of each cell to the bucket, and celld does not acknowledge a write |
| 39 | before the data is there (RPO=0). The loss of a node therefore cannot |
| 40 | lose an acknowledged write. To add a node to the fleet, point the node at |
| 41 | the bucket. The [ownership and fencing](fencing.md) page gives the full |
| 42 | mechanism and the exact properties that the bucket must provide. |
| 43 | |
| 44 | ## What do you build with cells |
| 45 | |
| 46 | A cell fits a workload that divides into named, stateful units: |
| 47 | |
| 48 | - **Real-time applications.** A multiplayer game, a chat room, or a |
| 49 | collaborative document is one cell. The cell holds the WebSocket |
| 50 | connections and the state of one room, so the room needs no lock and |
| 51 | no external message bus. |
| 52 | - **Agents.** Each AI agent is one cell. The cell holds the memory, the |
| 53 | schedule, and the inbox of one agent in its own SQLite database, and |
| 54 | an idle agent hibernates to the bucket, so a large agent fleet costs |
| 55 | almost nothing between events. |
| 56 | - **Sharded web applications.** One cell for each user, each tenant, or |
| 57 | each device shards the application from the start. The contention of |
| 58 | one shared database does not appear, because no shared database |
| 59 | exists. |
| 60 | |
| 61 | ## Contents |
| 62 | |
| 63 | - [What do you build with cells](#what-do-you-build-with-cells) |
| 64 | - [Install](#install) |
| 65 | - [Configure object storage](#configure-object-storage) |
| 66 | - [Deploy an application](#deploy-an-application) |
| 67 | - [Start a node](#start-a-node) |
| 68 | - [Add nodes](#add-nodes) |
| 69 | - [Diagnose a fleet](#diagnose-a-fleet) |
| 70 | - [Environment variables](#environment-variables) |
| 71 | - [Cloudflare compatibility](cloudflare-compat.md) |
| 72 | - [Ownership and fencing](fencing.md) |
| 73 | - [limitations](limitations.md) |
| 74 | - [Security](security.md) |
| 75 | - [Telemetry](telemetry.md) |
| 76 | - [Testing](testing.md) |
| 77 | - [WebAssembly](wasm.md) |
| 78 | |
| 79 | ## Install |
| 80 | |
| 81 | The installer downloads the `celld` binary. Replication occurs in the |
| 82 | celld process. A node does not need an external replicator. If your |
| 83 | project contains Worker code, `celld deploy` needs esbuild. An asset-only |
| 84 | project does not need esbuild. |
| 85 | |
| 86 | ```sh |
| 87 | curl -fsSL https://celld.dev/install.sh | sh |
| 88 | ``` |
| 89 | |
| 90 | If the installer tells you, add `~/.local/bin` to `PATH`. To install one |
| 91 | exact release, set `CELLD_VERSION` to the tag of that release, for example |
| 92 | `v0.0.1`. To go back to a previous release, run the installer again with |
| 93 | the tag of that release. The releases are on |
| 94 | [GitHub](https://github.com/denoland/celld/releases). Each release has a |
| 95 | GitHub Actions build attestation. To make sure that a downloaded file is |
| 96 | correct, run `gh attestation verify <asset> --repo denoland/celld`. |
| 97 | |
| 98 | ## Configure object storage |
| 99 | |
| 100 | For an S3-compatible bucket, celld uses the standard AWS credential |
| 101 | chain. For Cloudflare R2, do these steps. Create a bucket. Create an S3 |
| 102 | API token that has access to that bucket. Then set these variables: |
| 103 | |
| 104 | ```sh |
| 105 | export AWS_ACCESS_KEY_ID=... |
| 106 | export AWS_SECRET_ACCESS_KEY=... |
| 107 | export AWS_REGION=auto |
| 108 | export S3_ENDPOINT=https://ACCOUNT_ID.r2.cloudflarestorage.com |
| 109 | export CELLD_BUCKET=s3://YOUR-BUCKET |
| 110 | ``` |
| 111 | |
| 112 | For Google Cloud Storage, celld uses Application Default Credentials. |
| 113 | Create a bucket. Then authenticate with `gcloud auth application-default |
| 114 | login`, or point `GOOGLE_APPLICATION_CREDENTIALS` at a service-account |
| 115 | key that has access to the bucket. Then set the bucket: |
| 116 | |
| 117 | ```sh |
| 118 | export CELLD_BUCKET=gs://YOUR-BUCKET |
| 119 | ``` |
| 120 | |
| 121 | A `gs://` bucket takes no `S3_ENDPOINT` and no `AWS_*` credentials, and |
| 122 | celld ignores the storage region. |
| 123 | |
| 124 | On a Compute Engine instance, celld can use the attached service |
| 125 | account. The access scopes of the instance cap this credential, and the |
| 126 | default scope permits only storage reads. Create the instance with the |
| 127 | `cloud-platform` scope, so the IAM role of the service account controls |
| 128 | the access. |
| 129 | |
| 130 | For Azure Blob Storage, the bucket NAME is the container, and the |
| 131 | storage account comes from the environment. Create a container. Then |
| 132 | set the account and one credential: |
| 133 | |
| 134 | ```sh |
| 135 | export AZURE_STORAGE_ACCOUNT_NAME=YOUR-ACCOUNT |
| 136 | export AZURE_STORAGE_ACCOUNT_KEY=... |
| 137 | export CELLD_BUCKET=az://YOUR-CONTAINER |
| 138 | ``` |
| 139 | |
| 140 | celld accepts three Azure credential families: a storage account key, a |
| 141 | managed identity, and a workload identity. You must configure exactly one |
| 142 | family. A system-assigned managed identity needs only the account name. A |
| 143 | user-assigned managed identity can use `AZURE_CLIENT_ID`, `AZURE_OBJECT_ID`, |
| 144 | or `AZURE_MSI_RESOURCE_ID` as a selector. You must set exactly one of these |
| 145 | three selectors, because two selectors can name two different identities and |
| 146 | celld must not choose between them. |
| 147 | |
| 148 | celld reads the managed identity from the Azure instance metadata service. |
| 149 | An Azure VM and an AKS node supply that service. Azure App Service and Azure |
| 150 | Container Apps supply a different endpoint, so celld does not support a |
| 151 | managed identity on those two platforms. |
| 152 | |
| 153 | The standard AKS workload identity environment contains |
| 154 | `AZURE_AUTHORITY_HOST`, `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, and |
| 155 | `AZURE_FEDERATED_TOKEN_FILE`. celld accepts the public authority host, |
| 156 | `https://login.microsoftonline.com`, with or without a trailing slash, and it |
| 157 | rejects a sovereign or custom authority host. |
| 158 | |
| 159 | celld rejects each recognized Azure configuration variable outside these |
| 160 | families. This includes another credential source, an endpoint override, and |
| 161 | the OneLake endpoint. celld ignores an `AZURE_*` name that `object_store` |
| 162 | 0.11.2 does not recognize, because that name cannot change the client. |
| 163 | |
| 164 | A managed identity or a workload identity must have Azure Blob data-plane |
| 165 | permission to read, write, list, and delete blobs. The built-in `Storage Blob |
| 166 | Data Contributor` role supplies these permissions. See the |
| 167 | [Azure built-in roles](https://learn.microsoft.com/azure/role-based-access-control/built-in-roles#storage-blob-data-contributor). |
| 168 | An `az://` bucket takes no `S3_ENDPOINT` and no `AWS_*` credentials, and celld |
| 169 | ignores the storage region. |
| 170 | |
| 171 | celld qualifies an `az://` bucket for a production fleet: the |
| 172 | conditional-write contract and the multipart upload path were tested against |
| 173 | a live Azure account on 2026-08-18, under an account key, a VM managed |
| 174 | identity, and an AKS workload identity. See |
| 175 | [ownership and fencing](fencing.md). |
| 176 | |
| 177 | For local development against Azurite, set |
| 178 | `AZURE_STORAGE_USE_EMULATOR=true`. celld then accepts the emulator |
| 179 | endpoint. Azurite is a development store, so celld does not qualify it |
| 180 | for a fleet either. |
| 181 | |
| 182 | The bucket credentials give full control of the fleet. Keep them safe. The |
| 183 | bucket contains the deployments, the SQLite replicas, the ownership |
| 184 | records, the node leases, and the peer-authentication secret. |
| 185 | |
| 186 | A bucket value can add a key prefix: `s3://YOUR-BUCKET/PREFIX`. Every |
| 187 | object of the fleet then goes below `PREFIX/`, so two fleets can share one |
| 188 | bucket. A bucket value without a prefix keeps the objects at the root of |
| 189 | the bucket, therefore an existing fleet does not move its data. |
| 190 | |
| 191 | The store must provide conditional writes and read-after-write |
| 192 | consistency, because the ownership records depend on them. Amazon S3, |
| 193 | Cloudflare R2, Google Cloud Storage, Tigris, and Azure Blob Storage |
| 194 | qualify; MinIO (community edition), Backblaze B2, Hetzner, and |
| 195 | DigitalOcean Spaces do not. |
| 196 | See [ownership and fencing](fencing.md) for the exact requirements. |
| 197 | |
| 198 | ## Deploy an application |
| 199 | |
| 200 | If the project contains Worker code, install `esbuild` on `PATH`. Then run |
| 201 | `celld deploy` from an applicable Wrangler project: |
| 202 | |
| 203 | ```sh |
| 204 | git clone https://github.com/denoland/celld |
| 205 | cd celld/examples/counter |
| 206 | celld deploy . \ |
| 207 | --bucket "$CELLD_BUCKET" \ |
| 208 | --endpoint "$S3_ENDPOINT" \ |
| 209 | --region "$AWS_REGION" |
| 210 | ``` |
| 211 | |
| 212 | `celld deploy` accepts module Workers, Durable Object bindings, and static |
| 213 | assets. An asset project can include a Worker or be asset-only. The asset |
| 214 | functions include the assets binding, HTML handling, not-found handling, |
| 215 | worker-first routes, `_headers`, and `_redirects`. If the Wrangler |
| 216 | configuration contains an unknown key, the deploy stops with an error. See |
| 217 | the [limitations](limitations.md) for the current deployment boundary. |
| 218 | |
| 219 | ## Start a node |
| 220 | |
| 221 | For local development, the default listener is sufficient: |
| 222 | |
| 223 | ```sh |
| 224 | celld \ |
| 225 | --bucket "$CELLD_BUCKET" \ |
| 226 | --endpoint "$S3_ENDPOINT" \ |
| 227 | --region "$AWS_REGION" |
| 228 | ``` |
| 229 | |
| 230 | For a fleet node, bind the public and internal listeners separately. The |
| 231 | ingress can reach the public listener, and the other nodes can reach the |
| 232 | internal listener: |
| 233 | |
| 234 | ```sh |
| 235 | celld \ |
| 236 | --bucket "$CELLD_BUCKET" \ |
| 237 | --endpoint "$S3_ENDPOINT" \ |
| 238 | --region "$AWS_REGION" \ |
| 239 | --listen 0.0.0.0:8080 \ |
| 240 | --internal-listen 10.0.0.12:8081 \ |
| 241 | --advertise node-a.internal:8081 |
| 242 | ``` |
| 243 | |
| 244 | An explicit advertised address requires an explicit internal-listener address. |
| 245 | Set both command-line options, or use their equivalent environment variables. |
| 246 | celld also rejects an explicit non-loopback public listener without an explicit |
| 247 | internal listener. This rule identifies an obsolete one-listener configuration. |
| 248 | |
| 249 | celld cannot verify that an advertised hostname or a translated port reaches |
| 250 | the internal listener. You must route the advertised address to the internal |
| 251 | listener, and you must not route it to the public Worker listener. |
| 252 | |
| 253 | ## Add nodes |
| 254 | |
| 255 | Start each node with the same bucket settings. Give each internal listener a |
| 256 | different address that the other nodes can reach. Set `--advertise` to that |
| 257 | internal address. The nodes find each other through the leases in the bucket. |
| 258 | There is no join command and no fixed membership list. |
| 259 | |
| 260 | The bucket supplies discovery and authority. The bucket does not supply |
| 261 | network reachability. The peer HTTP protocol has a version, a body |
| 262 | signature, an HMAC, a clock limit, and replay protection. celld does not |
| 263 | terminate TLS. Put the advertised addresses on a private network that you |
| 264 | trust, or on an encrypted overlay such as WireGuard or Tailscale. The internal |
| 265 | listener also has an unauthenticated operator API, so do not show it to the |
| 266 | public internet. See the [security](security.md) page for the complete boundary. |
| 267 | |
| 268 | ## Shut down and roll out a node |
| 269 | |
| 270 | celld shuts a node down gracefully on SIGTERM or SIGINT, and these are the |
| 271 | signals `systemctl stop`, `docker stop`, and a Kubernetes pod delete send. |
| 272 | The `/__celld/health` path reports the node as unhealthy, so a load balancer |
| 273 | stops routing to it. The node |
| 274 | answers each new request with a 503 and closes the connection, so a client |
| 275 | retries on a healthy node. The node then hands every resident cell to a |
| 276 | peer by releasing its ownership, and it finishes the requests already in |
| 277 | flight. A cell that serves a request is handed off when that request |
| 278 | finishes. A peer takes over each released cell at once, so the node leaves |
| 279 | without the takeover gap of an abrupt kill. |
| 280 | |
| 281 | The internal listener continues to accept `/state` requests during the drain. |
| 282 | The response reports the `occupied`, `evicting`, and `restoring` values. The |
| 283 | public health response identifies the active drain with a 503 status. |
| 284 | |
| 285 | The handoff runs at most `CELLD_RELEASES` releases at the same time, and |
| 286 | the default is 128. This bound keeps a node with many cells from flooding |
| 287 | the object store at shutdown. `CELLD_SHUTDOWN_DRAIN_MS` bounds the whole |
| 288 | drain, and its default is 25000. The node exits when the handoff and the |
| 289 | in-flight requests finish, or when this many milliseconds pass, whichever |
| 290 | is first — an idle node exits immediately. You must set it below the stop |
| 291 | grace of your orchestrator, such as systemd `TimeoutStopSec` or Kubernetes |
| 292 | `terminationGracePeriod`, so the orchestrator does not send SIGKILL. |
| 293 | |
| 294 | To roll out a new version, use the rolling update of your orchestrator: |
| 295 | stop each node with SIGTERM, wait for its replacement to report healthy, |
| 296 | then move to the next node. celld has no rollout command, because the |
| 297 | health signal lets the orchestrator pace the roll. |
| 298 | |
| 299 | The upgrade from v0.1.0 to v0.2.0 must not be a rolling update. Stop |
| 300 | every v0.1.0 node, then start the v0.2.0 nodes. Two changes require |
| 301 | this: v0.2.0 nodes advertise the internal listener, so ownership |
| 302 | records that v0.1.0 nodes wrote name an address that v0.1.0 peers can |
| 303 | not follow to a v0.2.0 node; and v0.2.0 compacts replicated data into |
| 304 | block objects that a v0.1.0 reader can not restore. A fleet must not |
| 305 | mix the two versions. |
| 306 | |
| 307 | The upgrade from v0.2.1 to v0.3.0 can use a rolling update. v0.3.0 changes |
| 308 | the default durability from `bucket` to `fleet`. A single node keeps the |
| 309 | v0.2.1 behavior, and a fleet of two or more nodes activates fleet replication |
| 310 | automatically. |
| 311 | |
| 312 | Stage the v0.3.0 binary on every node, and restart one node at a time. Wait for |
| 313 | the replacement to report healthy before you restart the next node. A mixed |
| 314 | fleet stays safe, but a v0.3.0 node cannot replicate to a v0.2.x peer. The |
| 315 | v0.3.0 node therefore acknowledges writes through the bucket and retries until |
| 316 | the peer runs v0.3.0. |
| 317 | |
| 318 | Do not start a v0.2.x binary after that node runs v0.3.0 unless the shutdown log |
| 319 | contains `node-log close: sealed epoch`. A graceful stop attempts this seal. |
| 320 | A stop under load can leave the record open. A v0.2.x binary cannot read writes |
| 321 | that wait in the replicated log or bundle objects, so this downgrade can lose |
| 322 | acknowledged writes. |
| 323 | |
| 324 | The internal listener also provides an alpha operator API. `/state` reports the |
| 325 | node state, and `POST /shutdown` starts the same graceful handoff. The |
| 326 | `POST /shutdown?handoff=preserve` request prepares a clean same-node reload and |
| 327 | keeps the ownership records. A release can change this API, so keep the |
| 328 | operator tooling and the celld release together. |
| 329 | |
| 330 | ## Diagnose a fleet |
| 331 | |
| 332 | `celld diagnose` reads the node leases in the bucket. Then it sends a |
| 333 | probe to each live peer. It does not get a lease. It does not change |
| 334 | ownership. |
| 335 | |
| 336 | ```sh |
| 337 | celld diagnose \ |
| 338 | --bucket "$CELLD_BUCKET" \ |
| 339 | --endpoint "$S3_ENDPOINT" \ |
| 340 | --region "$AWS_REGION" |
| 341 | ``` |
| 342 | |
| 343 | To probe only some nodes, use `--peer NODE_ID` one or more times. The |
| 344 | report identifies expired records, unsafe or incorrect advertised |
| 345 | addresses, peers that it cannot reach, authentication failures, and |
| 346 | protocol versions that do not agree. |
| 347 | |
| 348 | Each node line also shows `restoring`. This value counts each cold route that |
| 349 | holds an activation permit or waits for one. A capacity waiter already holds |
| 350 | a permit, so the value counts each cold route once. During a rolling update, |
| 351 | you must wait for every node to report `restoring=0` before you restart the |
| 352 | next node. Therefore, one restart's cold work finishes before the next restart |
| 353 | removes more warm capacity. |
| 354 | |
| 355 | ## Environment variables |
| 356 | |
| 357 | For the full list, run `celld -h`. This table shows the primary settings: |
| 358 | |
| 359 | | variable | purpose | |
| 360 | | --- | --- | |
| 361 | | `CELLD_BUCKET` | The fleet bucket, and an optional key prefix. The same as `--bucket` | |
| 362 | | `S3_ENDPOINT` | The S3-compatible endpoint. The same as `--endpoint` | |
| 363 | | `AWS_REGION`, `AWS_DEFAULT_REGION` | The storage region | |
| 364 | | `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_SESSION_TOKEN` | Explicit AWS credentials. The standard AWS credential chain is also available | |
| 365 | | `GOOGLE_APPLICATION_CREDENTIALS`, `GOOGLE_SERVICE_ACCOUNT_KEY` | Google credentials for a `gs://` bucket. Application Default Credentials are also available | |
| 366 | | `AZURE_STORAGE_ACCOUNT_NAME` | The storage account for an `az://` bucket. The bucket NAME is the container | |
| 367 | | `AZURE_STORAGE_ACCOUNT_KEY` | The storage account key. Do not combine it with an identity selector | |
| 368 | | `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 | |
| 369 | | `AZURE_STORAGE_USE_EMULATOR` | Set to `true` to develop against Azurite. celld does not qualify Azurite for a production fleet | |
| 370 | | `CELLD_ADDR` | The public Worker listener. The same as `--listen` | |
| 371 | | `CELLD_INTERNAL_ADDR` | The peer and operator listener. The same as `--internal-listen` | |
| 372 | | `CELLD_ADVERTISE` | The internal address that peers can reach. The same as `--advertise` | |
| 373 | | `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 | |
| 374 | | `CELLD_NODE` | An explicit node-session ID | |
| 375 | | `CELLD_WATCH` | The local work directory for SQLite and replication | |
| 376 | | `CELLD_ESBUILD` | The path of the esbuild executable | |
| 377 | | `CELLD_ACTIVATIONS` | The limit for concurrent cold-cell activations (default: the available CPU count or 128, whichever is smaller) | |
| 378 | | `CELLD_OPERATION_DEADLINE_MS` | The deadline for a non-restore operation (default: 15000) | |
| 379 | | `CELLD_WORKER_LOADER` | Bind a Worker Loader (Code Mode) at this `env` name. A Worker can then start isolates at runtime. Off unless set (experimental) | |
| 380 | | `CELLD_MAX_LOADED_WORKERS` | The limit for concurrent loaded workers (default: 256) | |
| 381 | | `CELLD_MAX_RESIDENT_CELLS` | The hard limit for resident cells, enforced at admission | |
| 382 | | `CELLD_MAX_RSS_MB` | The memory threshold for pressure shedding, applied to the memory that the cells hold (default: 80% of the available memory; 0 disables the threshold and the absolute cap) | |
| 383 | | `CELLD_OUTPUT_GATE` | The default is `1`, so celld proves each write durable before it acknowledges the write. Set `0` to remove the replication wait and accept possible loss of an acknowledged write | |
| 384 | | `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 | |
| 385 | | `CELLD_LTX_COMPACTION_MIN_TXIDS` | The durable TXID distance that queues an L1 attempt (default: 256) | |
| 386 | | `CELLD_LTX_COMPACTIONS` | The node-wide limit for concurrent L1 attempts (default: 2) | |
| 387 | | `CELLD_VAR_*`, `CELLD_VARS_FILE` | Worker variable overrides | |
| 388 | | `RUST_LOG` | The runtime log filter | |
| 389 | |
| 390 | The help output also shows the advanced tuning switches and their |
| 391 | defaults. |
| 392 | |
| 393 | An unset variable selects its documented default. A Boolean variable accepts |
| 394 | only `0` or `1`. celld exits during startup when a supplied value is invalid. |