Self-hosting overview
Cairnflow can run on your own machines against your own bucket. There is no database, no coordinator service and no etcd to operate: every piece of state lives in object storage, and the runtime nodes only read and write it.
What you run
Section titled “What you run”| Binary | Role |
|---|---|
cairnflow |
The runtime. Serves the HTTP API, calls your services, keeps journals, state and timers in the bucket. |
cairn |
A thin CLI. Every command is one HTTP request to a node, so anything it does can also be done with curl. See CLI reference. |
cairn-ctl |
A recovery tool that reads and writes the bucket directly, with no node running: verify, backup, restore, trash. See Backup and restore. |
cairn-query-worker |
Not run by hand. cairnflow starts it as a child process for each SQL query sent to POST /query, so a hostile query cannot take the node down. Ship it in the same directory as cairnflow. See Security. |
cairnflow, cairn and cairn-ctl print the same version line with --version:
cairnflow <version> (data=<data format>, knows=<migration steps>)Use a cairn-ctl with the same knows= value as the nodes of your cluster; taking every binary
from the same build is the simplest way to guarantee it.
Shapes
Section titled “Shapes”| Shape | Minimal command | Use when |
|---|---|---|
| One node, local disk | cairnflow --data-dir /var/lib/cairnflow |
Development, a single machine, no failover |
| One node, in memory | cairnflow --main-store memory:// |
Tests. Everything is lost when the process exits. |
| One node, S3 | cairnflow --main-store s3://bucket/prefix |
One machine, with state outside the machine |
| Cluster, S3 | cairnflow --main-store s3://bucket/prefix --partitions N --host <address> on every node |
Failover, several nodes sharing one bucket |
Without --data-dir or --main-store, data goes to ./cairnflow-data, relative to the working
directory at startup. If both are given, --main-store wins.
A single node is a cluster of one: every node runs the same lease protocol, so moving from one node
to several is a matter of starting more nodes on the same bucket. The local-disk shape is the
exception: file:// storage supports one node only (see Object stores).
What the bucket holds
Section titled “What the bucket holds”Everything: journals, state, timers, queues, the API key book, deployments, and the ownership records of each key range. A node owns a range of keys through a lease written to the bucket with compare-and-swap. When a node stops renewing, another node takes its ranges over from the bucket.
This is why the store must support conditional writes. Each node checks its store at startup and refuses to run on one that does not.
| Flag | Default | Serves |
|---|---|---|
--port |
8080 |
Clients: invoke, admin and introspection API, /metrics, /health, and the web console under /ui |
--internal-port |
--port + 1 |
Other nodes only: cross-range messages, range hand-offs, forwarded requests. Every request is signed with the cluster secret. |
The ingress port returns 404 for internal routes. Keep the internal port reachable only from the
other nodes. A single node still opens it, because messages between ranges always travel over HTTP,
even to the same process.
By default a node listens on 127.0.0.1. Use --host 0.0.0.0 to accept connections from other
machines on a single node; in a cluster --host must be an address that peers can reach (see
Running a cluster).
Build from source
Section titled “Build from source”You need Rust (the toolchain named in rust-toolchain.toml installs itself through rustup),
protoc, CMake and a C++ compiler. To include the web console you also need Node.js 22.18 or
newer.
git clone https://github.com/cairnflowdev/cairnflow.gitcd cairnflowgit submodule update --init # the SlateDB fork in vendor/slatedb; the build needs it(cd ui && npm ci && npm run build) # optional: the web console, embedded at build timecargo build --releaseThe binaries are in target/release/. Without the console step, /ui/ shows a placeholder page.
A first node
Section titled “A first node”export CAIRNFLOW_ADMIN_KEY="cf_$(openssl rand -hex 24)"cairnflow --data-dir /var/lib/cairnflow --port 8080Authentication is on by default. CAIRNFLOW_ADMIN_KEY is a bootstrap key with the cluster-admin
role, at least 32 bytes long (the command above makes a 51-character key); a node with no key at all refuses to start unless you pass --no-auth, which is for a
development machine only. See Security.
Register a service that is already listening (for example one started with serve() on port 9080)
and call it:
export CAIRNFLOW_TOKEN="$CAIRNFLOW_ADMIN_KEY"cairn register http://127.0.0.1:9080cairn servicescairn invoke Greeter greet --input '"world"'The runtime calls your service at the URL you register, so that URL must be reachable from the node, not just from your laptop.
- Object stores: URIs, credentials, and which stores are supported.
- Running a cluster: several nodes, failover, splitting ranges.
- Docker: the image and a two-node compose example.
- Configuration: flags, environment variables and defaults.
- Security: keys, roles, console sign-in, SSO, TLS.
- Operations: health, metrics, logs, upgrades.
- Backup and restore:
cairn-ctl, backups, the trash.