Skip to content

v0.8.0 - scaled mode

Choose a tag to compare

@github-actions github-actions released this 30 Jul 10:48
· 4797 commits to main since this release
53f8de2

Scaled mode: nuthatch across machines. The same crates run as a writer pool, an independently-scaled serving tier, and a control plane. In-place safe from 0.7.x: no data migration, no config changes, and embedded mode is untouched - still one binary, still zero external services.

Embedded mode has not changed, and that is deliberate

Scaled mode is opt-in at build time (--features postgres-store). The binary attached to this release carries no database driver; cargo tree on the default build shows zero Postgres crates. If you run a nest or a roost on one box, this release changes nothing for you except a few bug fixes.

It is a trade, not an upgrade. Reach for it when a single machine can no longer hold your cursors inside their RAM budget, or when serving load and ingestion load want different dials. Otherwise a roost on one box is simpler, and that simplicity is the point.

The three roles (RFC-0022)

Role Command Owns
Control plane nuthatch control --db <postgres> desired state - what should run
Writer nuthatch worker --control-db … --hot-store … --chains … cursors it holds a lease on
Query-FE nuthatch serve --dir <nest> --hot-store <postgres> nothing - serves shared state
docker compose -f docker-compose.scaled.yml --profile fleet up \
  --scale writer=2 --scale fe=3

A role flag, never a fork. There are no #[cfg] branches in business logic; the only thing that changes is which hot store the runtime is handed.

worker is not dev. dev indexes a nest directory it owns outright and knows nothing about a control plane - running two of those against one store is the double-writer bug rather than a pool. A worker declares the chains it can host; the scheduler decides which it should, and the lease decides which it does. It refuses to start if it cannot determine its own id, because two workers sharing one look like a single worker to the registry.

The three things worth understanding

The control plane states intent; it commands nothing. POST /nests returning 200 does not mean the nest is running - it means the fleet has been told to run it. A writer picks it up on its next tick. There is deliberately no "start this nest on worker w3" endpoint: it would be the one call able to put a cursor somewhere the scheduler did not choose and the lease did not arbitrate.

Ownership is a lease, and the store enforces it. A cursor is held by one writer at a time. If a writer stalls - long GC, a paused container, a host that vanishes for ninety seconds - its lease expires and another writer takes over. When the original wakes up, its writes are refused by the store: every write carries a monotonic fence, and a stale fence is rejected inside the same transaction as the write. A worker checking its own lease first would be checking a fact that can expire between the check and the write. This is why --scale writer=N is safe.

The control plane and the lease are independent. A control-plane outage stops rescheduling, not ingestion. It follows that the two can legitimately disagree - a writer whose heartbeat has lapsed but whose lease is live keeps its cursor, and the scheduler's wish to rehome it is refused. That is correct. A plan is not permission.

Why is my nest not running?

GET /plan runs the same placement logic the writers run and says what could not be placed and why:

{"unplaceable":[{"chain":"base","rss_mb":2400,"reason":"toolargeforanyworker",
  "detail":"this cursor alone exceeds the largest worker's budget - adding workers will not help"}]}

noroomrightnow is fixed by adding a worker. toolargeforanyworker never is. Collapsing those into one message would send an operator shopping for hardware that cannot help.

Versions are pinned fleet-wide

Every FE node resolves an endpoint through the control plane (PUT /nests/<name>/pin), not through the registry's movable latest.

This fixes a bug that only exists across machines. If each node read latest for itself, then during an upgrade one node would serve the new schema while another served the old - the same endpoint answering differently depending on where the load balancer sent the request. Nothing errors; the only symptom is a consumer watching a column appear and disappear. A declared-but-unpinned endpoint is explicitly not servable: an FE refuses rather than guesses.

A compatible update re-pins one endpoint; a breaking one is a second endpoint served alongside the first, so existing consumers keep working.

Secrets never enter a bundle

Private RPC URLs and API keys live in the control plane keyed by nest, and a writer receives only the secrets of the nests it is assigned. The interface is write-only - list which keys exist, never read a value back.

Baking a credential into a content-addressed bundle would leak it and break addressing, since two nests differing only in credentials would hash differently. Because secrets sit outside, rotating one changes no bundle hash - it never invalidates segment reuse or forces a re-index.

Also in this release

  • nuthatch worker - the writer role: reconcile, lease, index what you are assigned.
  • nuthatch serve - the query-FE role, usable on its own to read-scale a single box.
  • nuthatch control - the control-plane API. Refuses to start off-localhost without NUTHATCH_CONTROL_TOKEN, rather than warning: it decides what an entire fleet runs.
  • A soak measurement. 23h on our production box: 459 MB and 427 MB against the 2048 MB per-cursor budget, flat at the end. Recorded in docs/prod-readiness.md §5 with what it does not prove - a window containing a workload transition cannot cleanly separate a slow leak from a working set that grew and settled.

What scaled mode is not

Per-tenant billing, metering, quotas, or authz between mutually-untrusting paying customers. That is a gateway's job in front of nuthatch and is deliberately out of scope. The line: multi-nest co-tenancy and distributed self-hosted mode are both in; charging strangers for isolated access is a different product.

Honest limits

Two things are not yet proven, and are stated here rather than discovered later:

  • The compose stack has not been brought up end to end. Every service in it maps to something tested, but the suites talk to Postgres directly.
  • Everything is verified on one host - several processes and connections against one database, which is genuinely equivalent for every invariant tested (a lease race does not care whether the contenders share a kernel). It is not a substitute for real network partitions or clock skew.

41 tests run against a live Postgres in CI, covering all six of RFC-0022's acceptance criteria.

Verifying the download

curl -fsSLO https://github.com/nuthatch-indexer/nuthatch/releases/download/v0.8.0/nuthatch-x86_64-unknown-linux-gnu.tar.gz
curl -fsSLO https://github.com/nuthatch-indexer/nuthatch/releases/download/v0.8.0/nuthatch-x86_64-unknown-linux-gnu.tar.gz.sha256
sha256sum -c nuthatch-x86_64-unknown-linux-gnu.tar.gz.sha256

Two images, two tarballs

Artifact Contains
nuthatch-x86_64-unknown-linux-gnu.tar.gz · :0.8.0 · :latest embedded - no database driver
nuthatch-scaled-x86_64-unknown-linux-gnu.tar.gz · :0.8.0-scaled scaled - worker, control, serve --hot-store

Scaled mode needs the -scaled artifact. worker and control still appear in the default binary's
--help - the CLI surface is shared - but running either returns a refusal naming the feature flag,
rather than failing mysteriously. A subcommand that disappears from help depending on build flags is
harder to diagnose than one that explains itself. Two builds
rather than one feature-fat binary because non-negotiable 1 says the primary deliverable runs with zero
external services - a binary carrying a Postgres driver is a different promise even when unused.
-scaled is deliberately not tagged latest.

Both linux/amd64, glibc floor 2.34.