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 | celld 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 | Worker projects deployed with `celld deploy` need |
| 39 | [esbuild](https://esbuild.github.io) on `PATH`; asset-only projects do not. |
| 40 | |
| 41 | The installer keeps verified releases under `~/.local/lib/celld/releases` and |
| 42 | atomically switches one `current` pointer. To remove celld, use the guarded |
| 43 | uninstaller: |
| 44 | |
| 45 | ```sh |
| 46 | curl -fsSL https://celld.dev/uninstall.sh | sh |
| 47 | ``` |
| 48 | |
| 49 | ## Container |
| 50 | |
| 51 | The release image contains the `celld` binary and is published for Linux |
| 52 | x86-64 and ARM64: |
| 53 | |
| 54 | ```sh |
| 55 | docker run --rm ghcr.io/denoland/celld --version |
| 56 | ``` |
| 57 | |
| 58 | Persist the runtime's local state and pass the standard AWS credential |
| 59 | environment through: |
| 60 | |
| 61 | ```sh |
| 62 | docker volume create celld-state |
| 63 | docker run --rm --network host \ |
| 64 | -e AWS_ACCESS_KEY_ID \ |
| 65 | -e AWS_SECRET_ACCESS_KEY \ |
| 66 | -e AWS_SESSION_TOKEN \ |
| 67 | -e CELLD_WATCH=/var/lib/celld/state \ |
| 68 | -v celld-state:/var/lib/celld \ |
| 69 | ghcr.io/denoland/celld \ |
| 70 | --bucket s3://my-cells-bucket \ |
| 71 | --endpoint https://ACCOUNT.r2.cloudflarestorage.com \ |
| 72 | --region auto \ |
| 73 | --listen 0.0.0.0:8080 \ |
| 74 | --advertise node-a.internal:8080 |
| 75 | ``` |
| 76 | |
| 77 | Drop `--endpoint`/`--region` for real AWS S3. Behind a load balancer, |
| 78 | give each node a distinct `--advertise` its peers can reach. |
| 79 | |
| 80 | ## Run it |
| 81 | |
| 82 | celld uses the standard AWS credential chain. Deploy to an S3-compatible |
| 83 | bucket, then start celld against the same bucket: |
| 84 | |
| 85 | ```sh |
| 86 | celld deploy . \ |
| 87 | --bucket s3://my-cells-bucket |
| 88 | |
| 89 | celld \ |
| 90 | --bucket s3://my-cells-bucket \ |
| 91 | --listen 0.0.0.0:8080 \ |
| 92 | --advertise 10.0.0.12:8080 |
| 93 | ``` |
| 94 | |
| 95 | Use `--endpoint` for another S3-compatible service and `--region` when it |
| 96 | cannot be inferred. A fleet runs one application, and every node loads its |
| 97 | latest successfully committed deployment from `deploy/current.json`. Run |
| 98 | `celld --help` for the complete command line. |
| 99 | Deployment objects use the documented types in `crates/celld/protocol.rs`. `celld |
| 100 | deploy` invokes `esbuild` from `PATH` for Worker code, accepts the supported |
| 101 | Wrangler config subset—including co-deployed or asset-only static |
| 102 | assets—and writes those objects directly. Every node discovers owners and |
| 103 | peers from bucket leases; there is no account or join service. |
| 104 | |
| 105 | Peer HTTP does not terminate TLS. Put every advertised address on a trusted |
| 106 | private network or an encrypted overlay such as WireGuard or Tailscale; do not |
| 107 | publish the peer port directly. A literal public IP is rejected unless |
| 108 | `--unsafe-public-advertise` is supplied explicitly. The first current node creates |
| 109 | `fleet/peer-auth.json` in the bucket. All peer requests are protocol-versioned, |
| 110 | body-bound, HMAC-authenticated, clock-bounded, and replay-protected with that |
| 111 | fleet secret. Treat access to the bucket and its credentials as fleet |
| 112 | administrator access. |
| 113 | |
| 114 | ## Operate a fleet |
| 115 | |
| 116 | `celld diagnose` enumerates every node lease by default, then performs a signed |
| 117 | direct probe of each live peer: |
| 118 | |
| 119 | ```sh |
| 120 | celld diagnose --bucket s3://my-cells-bucket |
| 121 | ``` |
| 122 | |
| 123 | The report keeps checking after an individual failure and distinguishes |
| 124 | expired records, malformed or unsafe advertise addresses, unreachable peers, |
| 125 | and incompatible protocols. It also prints each node's coarse resident-cell, |
| 126 | WebSocket, RSS, CPU, file-descriptor, pressure, and shedding sample. Pass one |
| 127 | or more `--peer NODE_ID` options to restrict the check. |
| 128 | |
| 129 | Pressure shedding is opt-in while the first release's safe defaults are being |
| 130 | measured. Set a resident-cell high and low watermark on loaded nodes: |
| 131 | |
| 132 | ```sh |
| 133 | CELLD_MAX_RESIDENT_CELLS=1000 \ |
| 134 | CELLD_RESIDENT_LOW_WATER=800 \ |
| 135 | celld --bucket s3://my-cells-bucket --listen 0.0.0.0:8080 \ |
| 136 | --advertise node-a.internal:8080 |
| 137 | ``` |
| 138 | |
| 139 | On Linux, `CELLD_MAX_RSS_MB` and `CELLD_MAX_CPU_PERCENT` add process-memory and |
| 140 | CPU triggers; the resident-cell watermark is portable. Under pressure, celld |
| 141 | durably replicates and fences least-recently used idle cells, publishes them as |
| 142 | unowned without resetting their epoch, and refuses to reacquire new unowned |
| 143 | cells until the low watermark is reached. A spare receives no assignment: it |
| 144 | acquires released cells through the same bucket protocol when normal traffic |
| 145 | reaches it. Cells with active work or live host WebSockets are not shed. |
| 146 | |
| 147 | ## Build from source |
| 148 | |
| 149 | ```sh |
| 150 | cargo build --locked |
| 151 | cargo test --locked |
| 152 | cargo clippy --all-targets --locked -- -D warnings |
| 153 | ``` |
| 154 | |
| 155 | The workspace builds the `celld` runtime. Its versioned object-storage |
| 156 | protocol lives in `crates/celld/protocol.rs`. Small Wrangler projects under `examples/` |
| 157 | exercise the supported Worker and Durable Object surface. |
| 158 | |
| 159 | The runtime and compatibility surface are still evolving. Public tests cover |
| 160 | the standalone engine smoke path; conformance against the Workers and Durable |
| 161 | Objects reference behavior, and a deterministic simulation of the distributed |
| 162 | protocol under fault injection, run before each release. |
| 163 | |
| 164 | ## Contributions |
| 165 | |
| 166 | Pull requests are disabled. Coding agents make it too easy to send a large, |
| 167 | low-context change that costs maintainers more time than it saves. Thoughtful |
| 168 | contributions are welcome; please understand the code, keep the patch focused, |
| 169 | and respect the review time you are asking for. |
| 170 | |
| 171 | Send a `git format-patch` attachment to [[email protected]](mailto:[email protected]). |
| 172 | |
| 173 | Contributor License Agreement: By emailing a patch, you certify that you have |
| 174 | the right to submit it and assign to Deno Land Inc. all rights in the patch |
| 175 | that you can assign. Where a right cannot be assigned, you grant Deno Land |
| 176 | Inc. a perpetual, irrevocable, |
| 177 | worldwide, royalty-free, transferable, sublicensable license to use, modify, |
| 178 | combine, relicense, redistribute, or publish the patch, in whole or in part, |
| 179 | with or without attribution. |
| 180 | |
| 181 | ## License |
| 182 | |
| 183 | [Apache-2.0](LICENSE) |
| 184 | |
| 185 | See the [limitations](docs/limitations.md) and |
| 186 | [security](docs/security.md) pages before operating a public fleet. |