Diffinery

homeflare/celldpublic

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