Diffinery

homeflare/celldpublic

celld/docs/README.md
164 lines · 6.3 KBRaw History
1# celld documentation
2
3celld is a self-hosted distributed system that you program like a database.
4Each Durable Object is its own SQLite database with a single writer, addressed
5by name and continuously replicated to an S3-compatible bucket you own. A fleet
6of celld nodes coordinates through that bucket alone — no control plane, no
7membership service, no consensus — running Cloudflare Workers and Durable
8Objects on your own machines.
9
10Because state is partitioned into one small database per object from the first
11line of code, applications shard by construction. The contention, hot spots,
12and blast-radius failures of a single shared database are designed out rather
13than managed: a runaway object can only affect its own cell.
14
15## Contents
16
17- [Install](#install)
18- [Configure object storage](#configure-object-storage)
19- [Deploy an application](#deploy-an-application)
20- [Start a node](#start-a-node)
21- [Add nodes](#add-nodes)
22- [Diagnose a fleet](#diagnose-a-fleet)
23- [Environment variables](#environment-variables)
24- [Cloudflare service compatibility](cloudflare-compat.md)
25- [Support matrix](support.md)
26- [v0.0.1 limitations](limitations.md)
27- [Security](security.md)
28
29## Install
30
31The installer downloads the `celld` binary. Running a node also needs
32[Litestream](https://litestream.io) on `PATH` (or `LITESTREAM_BIN`), and
33Worker projects deployed with `celld deploy` need esbuild. Asset-only
34projects do not:
35
36```sh
37curl -fsSL https://celld.dev/install.sh | sh
38```
39
40Put `~/.local/bin` on `PATH` if the installer asks you to. Install an exact
41immutable release by setting `CELLD_VERSION` to its tag, such as `v0.0.1`.
42Rerun the installer with a previous tag to roll back both binaries. Releases
43are published on [GitHub](https://github.com/denoland/celld/releases) with
44GitHub Actions build attestations; verify any downloaded asset with
45`gh attestation verify <asset> --repo denoland/celld`.
46
47## Configure object storage
48
49celld uses the standard AWS credential chain. For Cloudflare R2, create a
50bucket and an S3 API token with access to that bucket, then set:
51
52```sh
53export AWS_ACCESS_KEY_ID=...
54export AWS_SECRET_ACCESS_KEY=...
55export AWS_REGION=auto
56export S3_ENDPOINT=https://ACCOUNT_ID.r2.cloudflarestorage.com
57export CELLD_BUCKET=s3://YOUR-BUCKET
58```
59
60Treat access to the fleet bucket and its credentials as fleet-administrator
61access. The bucket contains deployments, SQLite replicas, ownership records,
62node leases, and the peer-authentication secret.
63
64## Deploy an application
65
66Install `esbuild` on `PATH` when the project includes Worker code, then run
67`celld deploy` from a supported Wrangler project:
68
69```sh
70git clone https://github.com/denoland/celld
71cd celld/examples/counter
72celld deploy . \
73 --bucket "$CELLD_BUCKET" \
74 --endpoint "$S3_ENDPOINT" \
75 --region "$AWS_REGION"
76```
77
78`celld deploy` supports module Workers, Durable Object bindings, and
79co-deployed or asset-only static assets. The asset subset includes the assets
80binding, HTML and not-found handling, worker-first routes, `_headers`, and
81`_redirects`. It refuses unknown Wrangler configuration rather than silently
82dropping it. See the [v0.0.1 limitations](limitations.md) for the current
83deployment boundary.
84
85## Start a node
86
87For local development, the default listener is enough:
88
89```sh
90celld \
91 --bucket "$CELLD_BUCKET" \
92 --endpoint "$S3_ENDPOINT" \
93 --region "$AWS_REGION"
94```
95
96For a reachable fleet node, bind the service and advertise the address other
97nodes and ingress can actually reach:
98
99```sh
100celld \
101 --bucket "$CELLD_BUCKET" \
102 --endpoint "$S3_ENDPOINT" \
103 --region "$AWS_REGION" \
104 --listen 0.0.0.0:8080 \
105 --advertise node-a.internal:8080
106```
107
108## Add nodes
109
110Start every node with the same bucket settings and a distinct reachable
111`--advertise` address. Nodes discover one another through bucket leases; there
112is no join command and no fixed membership list.
113
114The bucket provides discovery and authority, not network reachability.
115Peer HTTP is versioned, body-bound, HMAC-authenticated, clock-bounded, and
116replay-protected, but v0.0.1 does not terminate TLS. Put advertised addresses
117on a trusted private network or an encrypted overlay such as WireGuard or
118Tailscale. Do not expose the peer port directly to the public internet.
119
120## Diagnose a fleet
121
122`celld diagnose` reads the bucket's node leases and directly probes every live
123peer without acquiring a lease or changing ownership:
124
125```sh
126celld diagnose \
127 --bucket "$CELLD_BUCKET" \
128 --endpoint "$S3_ENDPOINT" \
129 --region "$AWS_REGION"
130```
131
132Use `--peer NODE_ID` one or more times to restrict the probes. The report
133distinguishes expired records, unsafe or malformed advertised addresses,
134unreachable peers, authentication failures, and protocol incompatibility.
135
136## Environment variables
137
138`celld -h` is the authoritative compact list. The main settings are:
139
140| variable | purpose |
141| --- | --- |
142| `CELLD_BUCKET` | Fleet bucket, equivalent to `--bucket` |
143| `S3_ENDPOINT` | S3-compatible endpoint, equivalent to `--endpoint` |
144| `AWS_REGION`, `AWS_DEFAULT_REGION` | Storage region |
145| `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_SESSION_TOKEN` | Explicit AWS credentials; the normal AWS credential chain is also supported |
146| `CELLD_ADDR` | Listener, equivalent to `--listen` |
147| `CELLD_ADVERTISE` | Peer-reachable address, equivalent to `--advertise` |
148| `CELLD_UNSAFE_PUBLIC_ADVERTISE` | Permit a literal public peer IP when set to `on` |
149| `CELLD_NODE` | Explicit node-session ID |
150| `CELLD_WATCH` | Local SQLite/Litestream working directory |
151| `LITESTREAM_BIN` | Litestream executable path |
152| `CELLD_ESBUILD` | esbuild executable path |
153| `CELLD_WORKERS` | Stateless Worker pool size (default: 16) |
154| `CELLD_ACTIVATIONS` | Concurrent cold-cell activation limit (default: the smaller of Worker count and 128) |
155| `CELLD_WORKER_LOADER` | Bind a Worker Loader (Code Mode) at this `env` name so a Worker can spawn isolates at runtime; off unless set (experimental) |
156| `CELLD_MAX_LOADED_WORKERS` | Cap on concurrent dynamically-loaded workers (default: 256) |
157| `CELLD_MAX_RESIDENT_CELLS`, `CELLD_RESIDENT_LOW_WATER` | Resident-cell pressure thresholds |
158| `CELLD_MAX_RSS_MB`, `CELLD_MAX_CPU_PERCENT` | Linux process-pressure thresholds |
159| `CELLD_VAR_*`, `CELLD_VARS_FILE` | Worker variable overrides |
160| `GOMEMLIMIT` | Litestream Go heap limit (default child: `512MiB`) |
161| `RUST_LOG` | Runtime log filter |
162
163The help output also names the advanced runtime tuning switches and their
164defaults.