Diffinery

homeflare/celldpublic

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