celld/README.md
| 1 | # celld |
| 2 | |
| 3 | Self-hosted, distributed **Durable Objects**. |
| 4 | |
| 5 | celld is an open-source daemon that runs Cloudflare Workers and Durable |
| 6 | Objects on your own machines. Each object is its own SQLite database. |
| 7 | celld addresses an object by name and replicates it to a bucket that you |
| 8 | own. The bucket can be S3-compatible, Google Cloud Storage, or Azure |
| 9 | Blob Storage. The nodes coordinate through that bucket alone, with no |
| 10 | control plane and no consensus. Because every object is its own small |
| 11 | database, applications shard by construction — the contention and |
| 12 | blast-radius failures of one shared database are designed out, not |
| 13 | managed. A cell that no node holds is inactive, and an inactive cell |
| 14 | costs nearly nothing. Learn more at |
| 15 | [celld.dev](https://celld.dev) or read the |
| 16 | [documentation](https://celld.dev/docs). |
| 17 | |
| 18 | ## How it works |
| 19 | |
| 20 | Every `celld` node embeds V8 and executes Wrangler bundles. The fleet shares |
| 21 | one bucket, which contains deployments, cell state, and small ownership |
| 22 | records. The bucket can be S3-compatible, Google Cloud Storage, or Azure |
| 23 | Blob Storage. Object-storage compare-and-swap ensures that exactly one |
| 24 | node owns a cell at a time, without a membership protocol, failure |
| 25 | detector, or consensus service. |
| 26 | |
| 27 | celld continuously replicates each cell's SQLite database to the bucket. |
| 28 | When a cell moves, or when an inactive cell activates, its new owner restores |
| 29 | that database and resumes execution. The bucket is the durable source of |
| 30 | truth; nodes are replaceable. |
| 31 | |
| 32 | ## Install |
| 33 | |
| 34 | The installer downloads the `celld` binary (provenance is verifiable with |
| 35 | `gh attestation verify`): |
| 36 | |
| 37 | ```sh |
| 38 | curl -fsSL https://celld.dev/install.sh | sh |
| 39 | ``` |
| 40 | |
| 41 | Put `~/.local/bin` on your `PATH` if the installer asks you to. |
| 42 | |
| 43 | Worker projects deployed with `celld deploy` need |
| 44 | [esbuild](https://esbuild.github.io) on `PATH`; asset-only projects do not. |
| 45 | |
| 46 | The installer keeps each release under `~/.local/lib/celld/releases` and points |
| 47 | one symlink at the current one. To remove celld, delete the symlink and the |
| 48 | releases: |
| 49 | |
| 50 | ```sh |
| 51 | rm `which celld` && rm -rf ~/.local/lib/celld |
| 52 | ``` |
| 53 | |
| 54 | ## Container |
| 55 | |
| 56 | The release image contains the `celld` binary and is published for Linux |
| 57 | x86-64 and ARM64: |
| 58 | |
| 59 | ```sh |
| 60 | docker run --rm ghcr.io/denoland/celld --version |
| 61 | ``` |
| 62 | |
| 63 | Persist the runtime's local state and pass the standard AWS credential |
| 64 | environment through: |
| 65 | |
| 66 | ```sh |
| 67 | docker volume create celld-state |
| 68 | docker run --rm --network host \ |
| 69 | -e AWS_ACCESS_KEY_ID \ |
| 70 | -e AWS_SECRET_ACCESS_KEY \ |
| 71 | -e AWS_SESSION_TOKEN \ |
| 72 | -e CELLD_WATCH=/var/lib/celld/state \ |
| 73 | -v celld-state:/var/lib/celld \ |
| 74 | ghcr.io/denoland/celld \ |
| 75 | --bucket s3://my-cells-bucket \ |
| 76 | --endpoint https://ACCOUNT.r2.cloudflarestorage.com \ |
| 77 | --region auto \ |
| 78 | --listen 0.0.0.0:8080 \ |
| 79 | --internal-listen 10.0.0.12:8081 \ |
| 80 | --advertise node-a.internal:8081 |
| 81 | ``` |
| 82 | |
| 83 | Drop `--endpoint` and `--region` for AWS S3. Expose port 8080 through the load |
| 84 | balancer, and keep port 8081 on the private network. |
| 85 | |
| 86 | ## Run it |
| 87 | |
| 88 | celld uses the standard AWS credential chain. Deploy to an S3-compatible |
| 89 | bucket, then start celld against the same bucket: |
| 90 | |
| 91 | ```sh |
| 92 | celld deploy . \ |
| 93 | --bucket s3://my-cells-bucket |
| 94 | |
| 95 | celld \ |
| 96 | --bucket s3://my-cells-bucket \ |
| 97 | --listen 0.0.0.0:8080 \ |
| 98 | --internal-listen 10.0.0.12:8081 \ |
| 99 | --advertise 10.0.0.12:8081 |
| 100 | ``` |
| 101 | |
| 102 | Use `--endpoint` for another S3-compatible service and `--region` when it |
| 103 | cannot be inferred. A `gs://` bucket selects Google Cloud Storage. celld then |
| 104 | uses the Cloud Storage XML API with generation preconditions. Authentication |
| 105 | uses Application Default Credentials. celld rejects an S3 `--endpoint` for a |
| 106 | `gs://` bucket, and it ignores the storage region: |
| 107 | |
| 108 | ```sh |
| 109 | celld deploy . --bucket gs://my-cells-bucket |
| 110 | celld --bucket gs://my-cells-bucket --listen 0.0.0.0:8080 \ |
| 111 | --internal-listen 10.0.0.12:8081 --advertise 10.0.0.12:8081 |
| 112 | ``` |
| 113 | |
| 114 | An `az://` bucket selects Azure Blob Storage, where the NAME is the |
| 115 | container. The storage account comes from `AZURE_STORAGE_ACCOUNT_NAME`. |
| 116 | celld requires exactly one storage account key, managed identity, or workload |
| 117 | identity. An AKS workload identity uses `AZURE_AUTHORITY_HOST`, |
| 118 | `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, and `AZURE_FEDERATED_TOKEN_FILE`. |
| 119 | The authority host must identify the public Azure cloud. A Microsoft Entra |
| 120 | identity needs data-plane permission to read, write, list, and delete blobs. |
| 121 | The `Storage Blob Data Contributor` role supplies these permissions. celld |
| 122 | rejects an S3 `--endpoint` for an `az://` bucket, and it ignores the storage |
| 123 | region. celld qualifies an `az://` bucket: the conditional-write contract and |
| 124 | the multipart upload path were tested against a live Azure account on |
| 125 | 2026-08-18, under each of the three credential families named above. See |
| 126 | [ownership and fencing](docs/fencing.md): |
| 127 | |
| 128 | ```sh |
| 129 | export AZURE_STORAGE_ACCOUNT_NAME=myaccount |
| 130 | celld deploy . --bucket az://my-cells-container |
| 131 | celld --bucket az://my-cells-container --listen 0.0.0.0:8080 \ |
| 132 | --internal-listen 10.0.0.12:8081 --advertise 10.0.0.12:8081 |
| 133 | ``` |
| 134 | |
| 135 | A fleet runs one application, and every node loads its |
| 136 | latest successfully committed deployment from `deploy/current.json`. Run |
| 137 | `celld --help` for the complete command line. |
| 138 | Deployment objects use the documented types in `crates/celld/protocol.rs`. `celld |
| 139 | deploy` invokes `esbuild` from `PATH` for Worker code, accepts the supported |
| 140 | Wrangler config subset—including co-deployed or asset-only static |
| 141 | assets—and writes those objects directly. Every node discovers owners and |
| 142 | peers from bucket leases; there is no account or join service. |
| 143 | |
| 144 | Peer HTTP and the operator API use the internal listener. Put every advertised |
| 145 | address on a trusted private network or an encrypted overlay such as WireGuard |
| 146 | or Tailscale. Do not publish the internal port. celld rejects a literal public |
| 147 | IP unless you supply `--unsafe-public-advertise`. An explicit advertised |
| 148 | address requires an explicit internal-listener address. celld cannot verify a |
| 149 | hostname or a translated port, so you must route the advertised address to the |
| 150 | internal listener. The first current node creates `fleet/peer-auth.json` in the |
| 151 | bucket. All peer requests are |
| 152 | protocol-versioned, body-bound, HMAC-authenticated, clock-bounded, and |
| 153 | replay-protected with that fleet secret. Treat access to the bucket and its |
| 154 | credentials as fleet administrator access. |
| 155 | |
| 156 | ## Operate a fleet |
| 157 | |
| 158 | `celld diagnose` enumerates every node lease by default, then performs a signed |
| 159 | direct probe of each live peer: |
| 160 | |
| 161 | ```sh |
| 162 | celld diagnose --bucket s3://my-cells-bucket |
| 163 | ``` |
| 164 | |
| 165 | The report keeps checking after an individual failure and distinguishes |
| 166 | expired records, malformed or unsafe advertise addresses, unreachable peers, |
| 167 | and incompatible protocols. It also prints each node's coarse resident-cell, |
| 168 | WebSocket, RSS, CPU, file-descriptor, pressure, and shedding sample. Pass one |
| 169 | or more `--peer NODE_ID` options to restrict the check. |
| 170 | |
| 171 | `celld d1` runs SQL and migrations against a deployed D1 database. It finds a |
| 172 | node through the same node leases, and that node sends the work to the node |
| 173 | that owns the database: |
| 174 | |
| 175 | ```sh |
| 176 | celld d1 migrations apply ledger --bucket s3://my-cells-bucket |
| 177 | ``` |
| 178 | |
| 179 | Set a hard resident-cell limit on each loaded node: |
| 180 | |
| 181 | ```sh |
| 182 | CELLD_MAX_RESIDENT_CELLS=1000 \ |
| 183 | celld --bucket s3://my-cells-bucket --listen 0.0.0.0:8080 \ |
| 184 | --internal-listen 10.0.0.12:8081 --advertise node-a.internal:8081 |
| 185 | ``` |
| 186 | |
| 187 | celld enables a memory threshold at 80% of the available memory by default. Set |
| 188 | `CELLD_MAX_RSS_MB` to change the threshold, or set it to `0` to disable memory |
| 189 | pressure shedding. celld measures the memory that the cells hold, and not the |
| 190 | resident set size of the process. The two differ, because the memory allocator |
| 191 | keeps some freed pages instead of returning them to the operating system. |
| 192 | Shedding a cell cannot return those pages, so a threshold on the resident set |
| 193 | size holds a node in pressure after the node gives every cell back. The `/state` |
| 194 | route reports both numbers. |
| 195 | |
| 196 | celld also applies an absolute cap to the resident set size of the process. The |
| 197 | cap is 95% of the available memory. It protects the node when the allocator |
| 198 | holds memory that shedding cannot return, because the operating system stops a |
| 199 | process that uses more memory than the machine has. The node logs a warning when |
| 200 | this cap applies. |
| 201 | |
| 202 | The cap is a share of the machine, and celld does not derive it from the |
| 203 | threshold. A `CELLD_MAX_RSS_MB` at or above 95% of the available memory therefore reaches |
| 204 | the cap. The cap is then the effective limit. The node decides on its resident |
| 205 | set size, and celld reports this at startup. `CELLD_MAX_RSS_MB=0` |
| 206 | disables the threshold and the cap together. When celld cannot read the size of |
| 207 | the available memory, it applies a cap of 125% of an explicit threshold. |
| 208 | |
| 209 | Each isolate also has a V8 heap limit, and this limit is separate from the |
| 210 | memory of the node. The default is 128 MB, and it matches the limit of a |
| 211 | Durable Object on Cloudflare. Set `CELLD_V8_HEAP_LIMIT_MB` to change it. The |
| 212 | limit decides how much state one isolate can hold, so it decides how many |
| 213 | hibernatable WebSocket clients a cell can carry. Each client holds state in the |
| 214 | heap. A cell holds approximately 50,000 clients with the default limit, and it |
| 215 | needs approximately 512 MB to hold 100,000 clients. |
| 216 | |
| 217 | An isolate that uses more than 90% of this limit refuses a new hibernatable |
| 218 | WebSocket, and the error names the heap. The refusal is not permanent, and the |
| 219 | isolate accepts a WebSocket again when the use of the heap falls under 90%. |
| 220 | |
| 221 | An isolate that reaches the limit stops more than an accept. It also stops the |
| 222 | materialization of a SQL result set, and that error names the heap too. celld |
| 223 | measures the heap before each event, and the isolate serves again when the use |
| 224 | of the heap falls under 75% of the limit. An idle isolate holds a dead heap |
| 225 | until something allocates again, so celld forces a collection when a |
| 226 | measurement is above that share. A restart of the process is not necessary. |
| 227 | |
| 228 | Under pressure, celld durably replicates and fences the least-recently used idle |
| 229 | cells. It then publishes the cells as unowned without resetting their epochs. |
| 230 | Those cells become inactive, and celld refuses to reacquire new unowned cells. |
| 231 | |
| 232 | Each limit releases separately. The threshold releases when the memory in use |
| 233 | falls to 80% of the threshold. The cap releases when the resident set size falls |
| 234 | to 80% of the cap. A crossing of one limit therefore does not hold the node |
| 235 | against the other. |
| 236 | |
| 237 | A spare receives no assignment. It acquires a released cell through the same |
| 238 | bucket protocol when normal traffic reaches it. celld does not shed a cell with |
| 239 | active work or a live host WebSocket. |
| 240 | |
| 241 | ## Contributions |
| 242 | |
| 243 | Pull requests are disabled. Coding agents make it too easy to send a large, |
| 244 | low-context change that costs maintainers more time than it saves. Thoughtful |
| 245 | contributions are welcome; please understand the code, keep the patch focused, |
| 246 | and respect the review time you are asking for. |
| 247 | |
| 248 | Send a `git format-patch` attachment to [[email protected]](mailto:[email protected]). |
| 249 | |
| 250 | Contributor License Agreement: By emailing a patch, you certify that you have |
| 251 | the right to submit it and assign to Deno Land Inc. all rights in the patch |
| 252 | that you can assign. Where a right cannot be assigned, you grant Deno Land |
| 253 | Inc. a perpetual, irrevocable, |
| 254 | worldwide, royalty-free, transferable, sublicensable license to use, modify, |
| 255 | combine, relicense, redistribute, or publish the patch, in whole or in part, |
| 256 | with or without attribution. |
| 257 | |
| 258 | ## License |
| 259 | |
| 260 | [Apache-2.0](LICENSE) |
| 261 | |
| 262 | See the [limitations](docs/limitations.md) and |
| 263 | [security](docs/security.md) pages before operating a public fleet. |