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 or Google Cloud Storage. The nodes |
| 9 | coordinate through that bucket alone, with no control plane and no |
| 10 | consensus. Because every object is its own small database, |
| 11 | applications shard by construction — the contention and blast-radius failures |
| 12 | of one shared database are designed out, not managed. A cell that no node |
| 13 | holds is inactive, and an inactive cell costs nearly nothing. Learn more at |
| 14 | [celld.dev](https://celld.dev) or read the |
| 15 | [documentation](https://celld.dev/docs). |
| 16 | |
| 17 | ## How it works |
| 18 | |
| 19 | Every `celld` node embeds V8 and executes Wrangler bundles. The fleet shares |
| 20 | one bucket, which contains deployments, cell state, and small ownership |
| 21 | records. The bucket can be S3-compatible or Google Cloud Storage. Object-storage compare-and-swap ensures that exactly one node owns a |
| 22 | cell at a time, without a membership protocol, failure detector, or consensus |
| 23 | service. |
| 24 | |
| 25 | celld continuously replicates each cell's SQLite database to the bucket. |
| 26 | When a cell moves, or when an inactive cell activates, its new owner restores |
| 27 | that database and resumes execution. The bucket is the durable source of |
| 28 | truth; nodes are replaceable. |
| 29 | |
| 30 | ## Install |
| 31 | |
| 32 | The installer downloads the `celld` binary (provenance is verifiable with |
| 33 | `gh attestation verify`): |
| 34 | |
| 35 | ```sh |
| 36 | curl -fsSL https://celld.dev/install.sh | sh |
| 37 | ``` |
| 38 | |
| 39 | Put `~/.local/bin` on your `PATH` if the installer asks you to. |
| 40 | |
| 41 | Worker projects deployed with `celld deploy` need |
| 42 | [esbuild](https://esbuild.github.io) on `PATH`; asset-only projects do not. |
| 43 | |
| 44 | The installer keeps each release under `~/.local/lib/celld/releases` and points |
| 45 | one symlink at the current one. To remove celld, delete the symlink and the |
| 46 | releases: |
| 47 | |
| 48 | ```sh |
| 49 | rm `which celld` && rm -rf ~/.local/lib/celld |
| 50 | ``` |
| 51 | |
| 52 | ## Container |
| 53 | |
| 54 | The release image contains the `celld` binary and is published for Linux |
| 55 | x86-64 and ARM64: |
| 56 | |
| 57 | ```sh |
| 58 | docker run --rm ghcr.io/denoland/celld --version |
| 59 | ``` |
| 60 | |
| 61 | Persist the runtime's local state and pass the standard AWS credential |
| 62 | environment through: |
| 63 | |
| 64 | ```sh |
| 65 | docker volume create celld-state |
| 66 | docker run --rm --network host \ |
| 67 | -e AWS_ACCESS_KEY_ID \ |
| 68 | -e AWS_SECRET_ACCESS_KEY \ |
| 69 | -e AWS_SESSION_TOKEN \ |
| 70 | -e CELLD_WATCH=/var/lib/celld/state \ |
| 71 | -v celld-state:/var/lib/celld \ |
| 72 | ghcr.io/denoland/celld \ |
| 73 | --bucket s3://my-cells-bucket \ |
| 74 | --endpoint https://ACCOUNT.r2.cloudflarestorage.com \ |
| 75 | --region auto \ |
| 76 | --listen 0.0.0.0:8080 \ |
| 77 | --internal-listen 10.0.0.12:8081 \ |
| 78 | --advertise node-a.internal:8081 |
| 79 | ``` |
| 80 | |
| 81 | Drop `--endpoint` and `--region` for AWS S3. Expose port 8080 through the load |
| 82 | balancer, and keep port 8081 on the private network. |
| 83 | |
| 84 | ## Run it |
| 85 | |
| 86 | celld uses the standard AWS credential chain. Deploy to an S3-compatible |
| 87 | bucket, then start celld against the same bucket: |
| 88 | |
| 89 | ```sh |
| 90 | celld deploy . \ |
| 91 | --bucket s3://my-cells-bucket |
| 92 | |
| 93 | celld \ |
| 94 | --bucket s3://my-cells-bucket \ |
| 95 | --listen 0.0.0.0:8080 \ |
| 96 | --internal-listen 10.0.0.12:8081 \ |
| 97 | --advertise 10.0.0.12:8081 |
| 98 | ``` |
| 99 | |
| 100 | Use `--endpoint` for another S3-compatible service and `--region` when it |
| 101 | cannot be inferred. A `gs://` bucket selects Google Cloud Storage. celld then |
| 102 | uses the Cloud Storage XML API with generation preconditions. Authentication |
| 103 | uses Application Default Credentials. celld rejects an S3 `--endpoint` for a |
| 104 | `gs://` bucket, and it ignores the storage region: |
| 105 | |
| 106 | ```sh |
| 107 | celld deploy . --bucket gs://my-cells-bucket |
| 108 | celld --bucket gs://my-cells-bucket --listen 0.0.0.0:8080 \ |
| 109 | --internal-listen 10.0.0.12:8081 --advertise 10.0.0.12:8081 |
| 110 | ``` |
| 111 | |
| 112 | A fleet runs one application, and every node loads its |
| 113 | latest successfully committed deployment from `deploy/current.json`. Run |
| 114 | `celld --help` for the complete command line. |
| 115 | Deployment objects use the documented types in `crates/celld/protocol.rs`. `celld |
| 116 | deploy` invokes `esbuild` from `PATH` for Worker code, accepts the supported |
| 117 | Wrangler config subset—including co-deployed or asset-only static |
| 118 | assets—and writes those objects directly. Every node discovers owners and |
| 119 | peers from bucket leases; there is no account or join service. |
| 120 | |
| 121 | Peer HTTP and the operator API use the internal listener. Put every advertised |
| 122 | address on a trusted private network or an encrypted overlay such as WireGuard |
| 123 | or Tailscale. Do not publish the internal port. celld rejects a literal public |
| 124 | IP unless you supply `--unsafe-public-advertise`. An explicit advertised |
| 125 | address requires an explicit internal-listener address. celld cannot verify a |
| 126 | hostname or a translated port, so you must route the advertised address to the |
| 127 | internal listener. The first current node creates `fleet/peer-auth.json` in the |
| 128 | bucket. All peer requests are |
| 129 | protocol-versioned, body-bound, HMAC-authenticated, clock-bounded, and |
| 130 | replay-protected with that fleet secret. Treat access to the bucket and its |
| 131 | credentials as fleet administrator access. |
| 132 | |
| 133 | ## Operate a fleet |
| 134 | |
| 135 | `celld diagnose` enumerates every node lease by default, then performs a signed |
| 136 | direct probe of each live peer: |
| 137 | |
| 138 | ```sh |
| 139 | celld diagnose --bucket s3://my-cells-bucket |
| 140 | ``` |
| 141 | |
| 142 | The report keeps checking after an individual failure and distinguishes |
| 143 | expired records, malformed or unsafe advertise addresses, unreachable peers, |
| 144 | and incompatible protocols. It also prints each node's coarse resident-cell, |
| 145 | WebSocket, RSS, CPU, file-descriptor, pressure, and shedding sample. Pass one |
| 146 | or more `--peer NODE_ID` options to restrict the check. |
| 147 | |
| 148 | Set a hard resident-cell limit on each loaded node: |
| 149 | |
| 150 | ```sh |
| 151 | CELLD_MAX_RESIDENT_CELLS=1000 \ |
| 152 | celld --bucket s3://my-cells-bucket --listen 0.0.0.0:8080 \ |
| 153 | --internal-listen 10.0.0.12:8081 --advertise node-a.internal:8081 |
| 154 | ``` |
| 155 | |
| 156 | celld enables an RSS threshold at 80% of the available memory by default. Set |
| 157 | `CELLD_MAX_RSS_MB` to change the threshold, or set it to `0` to disable memory |
| 158 | pressure shedding. Under pressure, celld durably replicates and fences the |
| 159 | least-recently used idle cells. It then publishes the cells as unowned without |
| 160 | resetting their epochs. Those cells become inactive, and celld refuses to |
| 161 | reacquire new unowned cells until RSS reaches 80% of the threshold. A spare |
| 162 | receives no assignment. It acquires a released cell through the same bucket |
| 163 | protocol when normal traffic reaches it. celld does not shed a cell with active |
| 164 | work or a live host WebSocket. |
| 165 | |
| 166 | ## Contributions |
| 167 | |
| 168 | Pull requests are disabled. Coding agents make it too easy to send a large, |
| 169 | low-context change that costs maintainers more time than it saves. Thoughtful |
| 170 | contributions are welcome; please understand the code, keep the patch focused, |
| 171 | and respect the review time you are asking for. |
| 172 | |
| 173 | Send a `git format-patch` attachment to [[email protected]](mailto:[email protected]). |
| 174 | |
| 175 | Contributor License Agreement: By emailing a patch, you certify that you have |
| 176 | the right to submit it and assign to Deno Land Inc. all rights in the patch |
| 177 | that you can assign. Where a right cannot be assigned, you grant Deno Land |
| 178 | Inc. a perpetual, irrevocable, |
| 179 | worldwide, royalty-free, transferable, sublicensable license to use, modify, |
| 180 | combine, relicense, redistribute, or publish the patch, in whole or in part, |
| 181 | with or without attribution. |
| 182 | |
| 183 | ## License |
| 184 | |
| 185 | [Apache-2.0](LICENSE) |
| 186 | |
| 187 | See the [limitations](docs/limitations.md) and |
| 188 | [security](docs/security.md) pages before operating a public fleet. |