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 | addressed by name and replicated to an |
| 8 | S3-compatible bucket you own; nodes coordinate through that bucket alone, with |
| 9 | no control plane or consensus. Because every object is its own small database, |
| 10 | applications shard by construction — the contention and blast-radius failures |
| 11 | of one shared database are designed out, not managed. Idle cells hibernate to |
| 12 | nearly nothing. Learn more at [celld.dev](https://celld.dev) or read the |
| 13 | [documentation](https://celld.dev/docs). |
| 14 | |
| 15 | ## How it works |
| 16 | |
| 17 | Every `celld` node embeds V8 and executes Wrangler bundles. The fleet shares an |
| 18 | S3-compatible bucket containing deployments, cell state, and small ownership |
| 19 | records. Object-storage compare-and-swap ensures that exactly one node owns a |
| 20 | cell at a time, without a membership protocol, failure detector, or consensus |
| 21 | service. |
| 22 | |
| 23 | Litestream continuously replicates each cell's SQLite database to the bucket. |
| 24 | When a cell moves or wakes up, its new owner restores that database and resumes |
| 25 | execution. The bucket is the durable source of truth; nodes are replaceable. |
| 26 | |
| 27 | ## Install |
| 28 | |
| 29 | The installer downloads the `celld` binary (provenance is verifiable with |
| 30 | `gh attestation verify`): |
| 31 | |
| 32 | ```sh |
| 33 | curl -fsSL https://celld.dev/install.sh | sh |
| 34 | ``` |
| 35 | |
| 36 | Put `~/.local/bin` on your `PATH` if the installer asks you to. |
| 37 | |
| 38 | celld follows the Unix convention of using ordinary external tools from |
| 39 | `PATH`: running a node needs [Litestream](https://litestream.io) (or set |
| 40 | `LITESTREAM_BIN`), and Worker projects deployed with `celld deploy` need |
| 41 | [esbuild](https://esbuild.github.io). Asset-only projects do not. The daemon |
| 42 | verifies Litestream at startup and exits immediately if it is missing. |
| 43 | |
| 44 | The installer keeps verified releases under `~/.local/lib/celld/releases` and |
| 45 | atomically switches one `current` pointer. To remove celld, use the guarded |
| 46 | uninstaller: |
| 47 | |
| 48 | ```sh |
| 49 | curl -fsSL https://celld.dev/uninstall.sh | sh |
| 50 | ``` |
| 51 | |
| 52 | ## Container |
| 53 | |
| 54 | The release image includes `celld`, the pinned Litestream binary, and esbuild |
| 55 | for `celld deploy`. It is published for Linux x86-64 and ARM64: |
| 56 | |
| 57 | ```sh |
| 58 | docker pull ghcr.io/denoland/celld:latest |
| 59 | docker run --rm ghcr.io/denoland/celld:latest --version |
| 60 | ``` |
| 61 | |
| 62 | `latest` and the Cargo version are convenient mutable tags. Use |
| 63 | `sha-<40-character-public-commit>` when the exact image must be immutable. |
| 64 | Persist the runtime's local state and pass the standard AWS credential |
| 65 | environment through: |
| 66 | |
| 67 | ```sh |
| 68 | docker volume create celld-state |
| 69 | docker run --rm --network host \ |
| 70 | -e AWS_ACCESS_KEY_ID \ |
| 71 | -e AWS_SECRET_ACCESS_KEY \ |
| 72 | -e AWS_SESSION_TOKEN \ |
| 73 | -e CELLD_WATCH=/var/lib/celld/state \ |
| 74 | -v celld-state:/var/lib/celld \ |
| 75 | ghcr.io/denoland/celld:latest \ |
| 76 | --bucket s3://my-cells-bucket \ |
| 77 | --endpoint https://ACCOUNT.r2.cloudflarestorage.com \ |
| 78 | --region auto \ |
| 79 | --listen 0.0.0.0:8080 \ |
| 80 | --advertise node-a.internal:8080 |
| 81 | ``` |
| 82 | |
| 83 | Drop `--endpoint`/`--region` for real AWS S3. Behind a load balancer, |
| 84 | give each node a distinct `--advertise` its peers can reach. |
| 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 | --advertise 10.0.0.12:8080 |
| 99 | ``` |
| 100 | |
| 101 | Use `--endpoint` for another S3-compatible service and `--region` when it |
| 102 | cannot be inferred. A fleet runs one application, and every node loads its |
| 103 | latest successfully committed deployment from `deploy/current.json`. Run |
| 104 | `celld --help` for the complete command line. |
| 105 | Deployment objects use the documented types in `crates/celld/protocol.rs`. `celld |
| 106 | deploy` invokes `esbuild` from `PATH` for Worker code, accepts the supported |
| 107 | Wrangler config subset—including co-deployed or asset-only static |
| 108 | assets—and writes those objects directly. Every node discovers owners and |
| 109 | peers from bucket leases; there is no account or join service. |
| 110 | |
| 111 | Peer HTTP does not terminate TLS. Put every advertised address on a trusted |
| 112 | private network or an encrypted overlay such as WireGuard or Tailscale; do not |
| 113 | publish the peer port directly. A literal public IP is rejected unless |
| 114 | `--unsafe-public-advertise` is supplied explicitly. The first current node creates |
| 115 | `fleet/peer-auth.json` in the bucket. All peer requests are protocol-versioned, |
| 116 | body-bound, HMAC-authenticated, clock-bounded, and replay-protected with that |
| 117 | fleet secret. Treat access to the bucket and its credentials as fleet |
| 118 | administrator access. |
| 119 | |
| 120 | ## Operate a fleet |
| 121 | |
| 122 | `celld diagnose` enumerates every node lease by default, then performs a signed |
| 123 | direct probe of each live peer: |
| 124 | |
| 125 | ```sh |
| 126 | celld diagnose --bucket s3://my-cells-bucket |
| 127 | ``` |
| 128 | |
| 129 | The report keeps checking after an individual failure and distinguishes |
| 130 | expired records, malformed or unsafe advertise addresses, unreachable peers, |
| 131 | and incompatible protocols. It also prints each node's coarse resident-cell, |
| 132 | WebSocket, RSS, CPU, file-descriptor, pressure, and shedding sample. Pass one |
| 133 | or more `--peer NODE_ID` options to restrict the check. |
| 134 | |
| 135 | Pressure shedding is opt-in while the first release's safe defaults are being |
| 136 | measured. Set a resident-cell high and low watermark on loaded nodes: |
| 137 | |
| 138 | ```sh |
| 139 | CELLD_MAX_RESIDENT_CELLS=1000 \ |
| 140 | CELLD_RESIDENT_LOW_WATER=800 \ |
| 141 | celld --bucket s3://my-cells-bucket --listen 0.0.0.0:8080 \ |
| 142 | --advertise node-a.internal:8080 |
| 143 | ``` |
| 144 | |
| 145 | On Linux, `CELLD_MAX_RSS_MB` and `CELLD_MAX_CPU_PERCENT` add process-memory and |
| 146 | CPU triggers; the resident-cell watermark is portable. Under pressure, celld |
| 147 | durably replicates and fences least-recently used idle cells, publishes them as |
| 148 | unowned without resetting their epoch, and refuses to reacquire new unowned |
| 149 | cells until the low watermark is reached. A spare receives no assignment: it |
| 150 | acquires released cells through the same bucket protocol when normal traffic |
| 151 | reaches it. Cells with active work or live host WebSockets are not shed. |
| 152 | |
| 153 | ## Build from source |
| 154 | |
| 155 | ```sh |
| 156 | cargo build --locked |
| 157 | cargo test --locked |
| 158 | cargo clippy --all-targets --locked -- -D warnings |
| 159 | ``` |
| 160 | |
| 161 | The workspace builds the `celld` runtime. Its versioned object-storage |
| 162 | protocol lives in `crates/celld/protocol.rs`. Small Wrangler projects under `examples/` |
| 163 | exercise the supported Worker and Durable Object surface. |
| 164 | |
| 165 | The runtime and compatibility surface are still evolving. Public tests cover |
| 166 | the standalone engine smoke path; conformance against the Workers and Durable |
| 167 | Objects reference behavior, and a deterministic simulation of the distributed |
| 168 | protocol under fault injection, run before each release. |
| 169 | |
| 170 | ## Contributions |
| 171 | |
| 172 | Pull requests are disabled. Coding agents make it too easy to send a large, |
| 173 | low-context change that costs maintainers more time than it saves. Thoughtful |
| 174 | contributions are welcome; please understand the code, keep the patch focused, |
| 175 | and respect the review time you are asking for. |
| 176 | |
| 177 | Send a `git format-patch` attachment to [[email protected]](mailto:[email protected]). |
| 178 | |
| 179 | Contributor License Agreement: By emailing a patch, you certify that you have |
| 180 | the right to submit it and assign to Deno Land Inc. all rights in the patch |
| 181 | that you can assign. Where a right cannot be assigned, you grant Deno Land |
| 182 | Inc. a perpetual, irrevocable, |
| 183 | worldwide, royalty-free, transferable, sublicensable license to use, modify, |
| 184 | combine, relicense, redistribute, or publish the patch, in whole or in part, |
| 185 | with or without attribution. |
| 186 | |
| 187 | ## License |
| 188 | |
| 189 | [MIT](LICENSE) |
| 190 | |
| 191 | See the [support matrix](docs/support.md), [limitations](docs/limitations.md), |
| 192 | and [security](docs/security.md) before operating a public fleet. |