Diffinery

homeflare/celldpublic

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