denoland/celldPublic

self-hosted, distributed Durable Objects

v0.4.1

You can do a rolling upgrade from v0.4.0.

Highlights:

- **Balance cell ownership across the fleet.** A node that joins takes
  hibernated cells from the nodes that hold the most, so it carries its share
  within minutes instead of waiting for new traffic. The fleet evens out
  again after a node leaves. One node samples the leases for the whole fleet,
  so the cost does not grow with the square of the fleet.
- **Restore a large cell page by page.** The cell reads each page from the
  object store on first use, so it serves requests before the download
  completes. A large cell also hands off through its LTX chain instead of a
  whole-database snapshot.
- **Queue throughput improves by an order of magnitude.** Producer calls
  share transactions and durability rounds, and each message gets a
  time-ordered id. One Queue sustained 7,357 sends per second over a
  300,000-send soak with exact delivery, up from a few hundred.
- **Fewer false durability timeouts under load.** The budget measures a
  stall: a queued write waits while the node keeps landing proofs. A follower
  commits a burst of frames as one fsync chain, and CRC64 verification uses
  SIMD.
- **Alarms scale to the due work.** The waker lists one bucket per armed
  minute and opens only the due ones. Only the elected waker probes the
  fleet, and the activation bound derives from store latency, so alarms of
  evicted cells fire on time under load.
- **Recover from a whole-fleet restart.** A restarting node serves follower
  fragments while it recovers its own predecessor, so nodes that restart
  together recover acknowledged writes. Recovery checkpoints its progress and
  holds a heartbeat, so a retry skips finished work and peers do not repeat
  it.
- **Durable Object facets.** `ctx.facets` provides `get()`, `abort()`, and
  `delete()`. Each facet gets an isolated SQLite database that celld
  replicates with the root object.
- **More Node.js and web platform APIs.** `node:fs`, `node:os`,
  `node:diagnostics_channel`, a read-only `/bundle`, and a per-request
  `/tmp`. `HTMLRewriter`, `EventSource`, `MessageChannel`, the `Cache` API
  surface, outbound TCP through `cloudflare:sockets`, and Web Crypto KDF
  derivation, key wrapping, and RSA signing.
- **A tighter output gate.** An error answer, each chunk of a streaming body,
  a call into a loaded Worker, and the answer of a handler that fails after
  it commits all wait for the proof of the writes they depend on.
  `storage.sync()` returns after the cell's writes are proven durable, and a
  rollback discards writes submitted without `await`.
- **A lease reports why it lost authority.** A self-fence names its cause,
  and a failed renewal retries before the authority expires.
- **Operator commands page.** A cell listing and a KV bulk export no longer
  load a namespace into memory. A lease records store outcomes and owned
  cell count, so `celld diagnose` shows each node's load. `celld dev --clean`
  discards the local state.

Issues fixed:

- #176
- #178
- #179
- #180
- #182
- #183
- #184
- #185
- #186

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Bert Belder <bertbelder@gmail.com>
Co-authored-by: Daniel Acuna <daniel.acuna@instacart.com>
Co-authored-by: Daniel Levi-Minzi <51272568+dleviminzi@users.noreply.github.com>
Co-authored-by: Josh Collinsworth <josh@deno.com>
Co-authored-by: Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com>
Co-authored-by: Yusuke Tanaka <yusuktan@maguro.dev>
YTNWJCDMDABBBIRDRyan Dahl and 7 others authored
10cb130Patch
Parenta52f990
106 files changed+36026-3577
StackedSplit
Cargo.lock+264 −5
Cargo.toml+23 −11
README.md+52 −6
crates/celld/Cargo.toml+5 −2
crates/celld/actor.rs+478 −102
crates/celld/assets.rs+10 −1
crates/celld/asyncrt.rs+168 −18
crates/celld/bucket.rs+278 −36
crates/celld/cell_cli.rs+10 −1
crates/celld/cli_options.rs+9 −13
crates/celld/control_plane.rs+9 −7
crates/celld/d1_cli.rs+15 −10
crates/celld/dead_node_gc.rs+60 −10
crates/celld/deploy.rs+67 −7
crates/celld/dev.rs+224 −33
crates/celld/drain_token.rs+47 −5
crates/celld/env_vars.rs+61 −2
crates/celld/fleet.rs+70 −43
crates/celld/host_services.rs+44 −0
crates/celld/js.rs+4605 −674
crates/celld/js/bootstrap.rs+55 −2
crates/celld/js/cache.js+105 −0
crates/celld/js/crypto.js+252 −60
crates/celld/js/crypto.rs+264 −94
crates/celld/js/event_source.js+289 −0
crates/celld/js/harness.js+1502 −190
crates/celld/js/html_rewriter.js+498 −0
crates/celld/js/html_rewriter.rs+687 −0
crates/celld/js/input_gate_lifecycle.rs+256 −0
crates/celld/js/message_channel.js+111 −0
crates/celld/js/modules.rs+33 −7
crates/celld/js/node_crypto.js+11 −14
crates/celld/js/node_diagnostics_channel.js+242 −0
crates/celld/js/node_os.js+248 −0
crates/celld/js/r2_ops.rs+4 −2
crates/celld/js/sockets.js+231 −0
crates/celld/js/storage_ops.rs+286 −5
crates/celld/js/tcp.rs+289 −0
crates/celld/js/websocket.rs+471 −131
crates/celld/kv_cli.rs+139 −59
crates/celld/lib.rs+7 −3
crates/celld/ltx_repl.rs+1039 −225
crates/celld/machine.rs+53 −0
crates/celld/main.rs+1046 −235
crates/celld/main/cli.rs+25 −12
crates/celld/main/peer_tunnel.rs+62 −8
crates/celld/main/websocket.rs+196 −63
crates/celld/node_log.rs+1424 −350
crates/celld/node_log/recovery_progress.rs+150 −0
crates/celld/ownership_store.rs+607 −26
crates/celld/peer_auth.rs+6 −13
crates/celld/pool.rs+159 −33
crates/celld/protocol.rs+34 −1
crates/celld/replication.rs+6 −0
crates/celld/runtime.rs+718 −161
crates/celld/startup.rs+3 −12
crates/celld/storage.rs+549 −40
crates/celld/telemetry.rs+321 −104
crates/celld/wake.rs+119 −11
crates/logic/drain.rs+38 −15
crates/logic/durability.rs+76 −0
crates/logic/format.rs+40 −0
crates/logic/gate.rs+29 −29
crates/logic/isolate.rs+22 −0
crates/logic/lib.rs+1130 −171
crates/logic/log_tier.rs+64 −1
crates/logic/output_gate.rs+139 −26
crates/logic/peer.rs+5 −3
crates/logic/rebalance.rs+163 −0
crates/logic/schedule.rs+15 −2
crates/logic/types.rs+185 −12
crates/logic/wake.rs+44 −10
crates/ltx/Cargo.toml+4 −0
crates/ltx/README.md+4 −1
crates/ltx/src/bundle.rs+24 −18
crates/ltx/src/client/epochs.rs+176 −0
crates/ltx/src/client/mod.rs+24 −0
crates/ltx/src/client/object_store.rs+406 −16
crates/ltx/src/codec.rs+64 −3
crates/ltx/src/db.rs+359 −110
crates/ltx/src/error.rs+3 −0
crates/ltx/src/lib.rs+2 −0
crates/ltx/src/ltx.rs+15 −35
crates/ltx/src/paged.rs+546 −0
crates/ltx/src/paged_vfs.rs+681 −0
crates/ltx/src/replica_compactor.rs+12 −1
crates/ltx/src/replica_url.rs+8 −9
docs/README.md+279 −49
docs/cloudflare-compat.md+281 −118
docs/guarantees.md+100 −35
docs/library-api.md+0 −60
docs/limitations.md+4 −2
docs/telemetry.md+21 −1
docs/wasm.md+1 −1
examples/README.md+4 −2
examples/opencode/README.md+35 −0
examples/opencode/index.js+144 −0
examples/opencode/package-lock.json+8679 −0
examples/opencode/package.json+10 −0
examples/opencode/wrangler.jsonc+10 −0
examples/pi/.gitignore+1 −0
examples/pi/README.md+43 −0
examples/pi/index.js+94 −0
examples/pi/package-lock.json+3011 −0
examples/pi/package.json+11 −0
examples/pi/wrangler.jsonc+24 −0