Skip to content
Contents

Self-Hosted

How Rindle runs server-side, and how it scales

Coming soon. Rindle is not available to self-host yet.

Rindle is one binary, rindle. On a single machine it is one server process and one database file. To scale, it splits into a leader and any number of read followers, the way Postgres scales reads with replicas, except that followers also run the live queries.

The leader and the followers are the same process in two postures, declared in config: "posture": "authority" owns its store and serves writes, and the default, "follower", tails one upstream and answers every write route with a 409 naming it. Posture is declared rather than inferred, so a follower whose sources went missing in a bad deploy fails to start instead of promoting itself.

This is the same architecture Cloud Rindle runs.

Single Server

The simplest deployment, and what ./rindle up runs locally. Write a config:

{
  "db": "/var/lib/rindle/data.db",
  "posture": "authority",
  "httpPort": 7600,
  "bindHost": "0.0.0.0",
  "apiToken": "…",
  "adminToken": "…"
}

And start it:

rindle serve --config rindle.json

Rindle serves everything on httpPort. Give your server its address and API token as RINDLE_URL and RINDLE_API_TOKEN. A proxy in front of Rindle must pass WebSocket upgrades through.

apiToken is what your app sends; adminToken is a second credential for the operator routes (/admin/*, /re-bootstrap, /shed, /stats), so the token your app server holds cannot also restart the daemon.

One process serves reads, writes, migrations, and live queries. The data is one file — a copy-on-write paged tree with shadow-paged commits, one writer, and readers pinned to immutable versions — plus a pool of query workers, one per CPU by default.

A single server using the default file store has no built-in replication. Back it up with volume or filesystem snapshots. To move to the replicated setup later, give it an archive and a fanoutPort and point followers at it; the store is the same file either way.

Optional Object Storage

A standalone authority can keep its paged tree in S3-compatible object storage instead. Replace db with storage in its config; keep the other server and authentication options:

{
  "posture": "authority",
  "httpPort": 7600,
  "storage": {
    "type": "object",
    "store": "s3",
    "baseKey": "tenants/my-app/db",
    "localDir": "/var/lib/rindle/my-app",
    "publishIntervalMs": 60000,
    "maxLayers": 8,
    "warmBytes": 536870912
  }
}

Configure the bucket and credentials with AWS_BUCKET, AWS_REGION, and the standard AWS credential environment. For R2 or MinIO, also set AWS_ENDPOINT or AWS_ENDPOINT_URL_S3; local HTTP endpoints require AWS_ALLOW_HTTP=true. The existing RINDLE_BACKUP_PREFIX, when set, prefixes these objects too. Each database needs its own baseKey. For local development, "store": "filesystem", "path": "/path/to/objects" uses a directory as the object store.

The writable overlay and redo log live in localDir. The optional warmBytes cache holds evictable copies of published pages; it defaults to zero. Local commit behavior, including commitSync, is the same as for a file-backed authority. A process restart recovers unpublished commits from the local state. After losing that state, a fresh server opens the latest published tree directly from object storage, including its schema and migration history.

publishIntervalMs defaults to 60000 and schedules publication of new checkpoints as delta layers. It is a recovery-point target: uploads, retries, and outages can extend the time before a commit becomes recoverable without local state. /stats reports storage.localVersion, storage.publishedVersion, storage.publishingVersion, storage.publishedAtMs, and storage.lastError; the published version advances only after publication succeeds. SIGTERM or Ctrl-C flushes the final committed version before exiting, and a failed final publication causes a nonzero exit; a second signal exits immediately, without waiting for a flush that an unreachable bucket is holding up.

A server starts even when its catch-up publication fails: the local store and redo log still hold every unpublished commit, so it serves reads and writes and retries on publishIntervalMs with the reason in storage.lastError. The one startup failure it refuses is being fenced — another writer owns the same baseKey — because then it must not serve that tree at all.

maxLayers defaults to 8. A publication compacts the current layers into parts when this limit is reached. A single background worker uploads a pinned checkpoint while the authority continues serving reads and writes. storage.publishingVersion identifies its in-flight checkpoint; publishedVersion advances only when that upload succeeds. Startup and graceful shutdown wait for their required publication. Collection and pin operations use the same worker, so they also leave normal requests responsive.

Object storage keeps a rolling seven-day history window and at least two published versions by default. An hourly sweep deletes expired history and unreachable parts or layers; objects younger than one hour have an orphan grace period. Shared parts, the current tree, explicitly pinned versions, and older bases still held by local readers stay protected. The window covers publication points; unpublished local commits become recoverable remotely only when publication succeeds. Uploads, maintenance, retries, and outages can extend that delay.

A retained version whose objects have gone missing — a lifecycle rule that did not leave them intact, a stray delete — is dropped from retention rather than failing the sweep, which would otherwise stop all collection for good. The sweep raises the retention floor past it and names it in unverifiableVersions in its report; a non-empty list means the bucket lost data it was told to keep. A version held by a pin is not dropped: the sweep refuses until that pin is removed, so discarding it stays an operator decision.

Override the defaults inside storage:

"gc": {
  "intervalMs": 3600000,
  "retainForMs": 604800000,
  "keepVersions": 2,
  "orphanGraceMs": 3600000
}

Set "gc": false to disable automatic collection. The operator routes below remain available; a manual collection then uses the default policy. A manual collection does not reschedule the automatic one. /stats exposes storage.pins, storage.retentionFloor, storage.pinLastError, and storage.gc with the last report and error.

Use adminToken for these POST routes:

Route JSON body Result
/admin/storage/pin {"name":"release","version":42} Preserves that published version until this pin is removed or replaced.
/admin/storage/unpin {"name":"release"} Removes the pin; normal retention applies again.
/admin/storage/gc {} Runs a sweep and returns retained versions and deletion counts.

Omit version to pin the latest published checkpoint. To include recent writes, first wait until storage.publishedVersion reaches their committed version. Pins survive restart. A version that has expired cannot be pinned again unless another pin already protects it. Historical versions written by older binaries without publication confirmations cannot be newly pinned; their history is retained conservatively during the configured window. External readers using an older historical root must keep a pin for it.

New publications use pointer format 4, which records retention and pins. Existing formats 1–3 remain readable; binaries that only understand those older formats cannot reopen a format-4 head. Bucket lifecycle rules must leave retained objects intact.

This storage option is supported only with "posture": "authority" and without fanoutPort or archive. Followers and authorities serving followers continue to use the file store. Omitting storage, or specifying {"type":"file"}, preserves the existing db configuration.

Replicated

The replicated deployment Your API server talks to the edge. The edge sends writes to the leader and assigns each client to one of several followers. The leader streams its log to every follower and ships it to object storage. New followers restore from object storage, then catch up from the leader. API SERVER your app EDGE rindle edge one public endpoint LEADER rindle serve · authority owns the writes FOLLOWER 1 rindle serve · live queries FOLLOWER 2 rindle serve · live queries FOLLOWER N add more for more reads OBJECT STORAGE S3, R2, … all calls writes clients journal restore
Process Command Does
Leader rindle serve ("posture": "authority") Commits every write and keeps the log of changes
Follower rindle serve (the default posture) Holds a full replica, serves reads, and runs live queries
Edge rindle edge The one public endpoint. Routes writes to the leader and each client to its follower
Backup producer rindle backup producer Turns the archived log into periodic snapshots

One binary, four roles. rindle serve is the daemon in both postures — a copy of the binary named rindled runs it too, which is what the fleet’s unit files exec.

Your app talks only to the edge, and pages read their streams from it, with the same RINDLE_URL and client code as a single server.

Writes

All writes go to the leader. Each transaction uses a private snapshot, so multiple transactions can remain open. One committer validates and replays their writes at commit. The interactive body does not hold the writer or change live query results. Conflicting transactions return 409 TRANSACTION_CONFLICT. The caller decides whether to repeat the transaction.

Two limits bound each transaction. sessionDeadlineMs (default 5 s) measures idle time after the last operation finishes. sessionMaxMs (default 30 s) measures total time from begin. The server admits at most 1024 open transactions and 32 unanswered write requests. A full limit returns 503. Schema migrations wait for open transactions. New transactions wait behind a queued migration.

A read-only /db/execute or /db/batch takes no writer at all: it is answered from the latest committed state, so it neither blocks writes nor waits for one.

Each commit gets a version, and its log record is written in the same commit as the data, so the log can never disagree with the database. The leader streams the log to every follower and ships it to object storage. Electing a new lineage fences the old leader at startup, so a leader that has been replaced cannot accept writes.

A commit returns once its log record is appended, and the log and pages are synced to disk at checkpoints — "commitSync": "normal", the default. A crashed process loses nothing; a power loss can drop the commits since the last sync, and never corrupts the store. That is SQLite’s WAL at synchronous=NORMAL. Set "commitSync": "full" on the leader to sync the log on every commit, so a commit that returned survives a power loss; each commit then waits for one device flush, which on macOS is a full F_FULLFSYNC of several milliseconds. Followers refuse the key: their commits write no log of their own.

Reads and Live Queries

Each follower holds a full copy of the database. It tails the leader’s log, applies each commit, and pushes the change through its live queries, so subscribers get only the rows that changed. A query’s state is shared by every subscriber to it, and queries are spread across a pool of worker threads.

A follower that restarts resumes from its store’s own cursor. A new follower, or one that fell too far behind, restores the latest snapshot from object storage and catches up from there. It reports not-ready on /readyz, and takes no traffic, until it has caught up.

Followers are the unit of scale. Add one to add capacity for reads and live queries; the leader and the other followers don’t change.

Sessions

A client’s subscriptions live on one follower — a live query is a set of maintained views, and those views are on one thread of one process. When the client gets its first stream token, the edge assigns it a follower, balancing load across them. The stream token names that follower, so the client’s stream and its subscribes all reach it, and a token presented to any other follower is refused.

A Public Stream Port

Your server calls every Rindle route except /db/stream, the one route untrusted clients connect to.

By default, Rindle serves them all on one port. If your server reaches Rindle over a private network, you can give the stream its own port for added security: set wsPort to move /db/stream there, and expose only that port to the internet.

A public stream port Your client calls your server, and opens its stream on Rindle's public stream port, 7601. Your server reaches Rindle's other routes on port 7600 over a private network that the internet can't reach. PRIVATE NETWORK YOUR CLIENT browser, app YOUR SERVER RINDLE :7600 server routes :7601 /db/stream your endpoints /db/subscribe, /db/execute /db/stream · the only public port
{
  "httpPort": 7600,
  "wsPort": 7601
}

Durability

The leader ships its log to object storage (S3, R2, MinIO, or a filesystem) continuously, on an RPO cadence (archive.rpoMs, 60 s by default). The backup producer — a separate process that never opens the leader’s store — turns the archive into periodic snapshots and keeps the newest K. Together they give point-in-time restore to any commit in that window:

rindle backup ls
rindle backup restore-follower --source main --out restored.db \
  --at 1791500000000
rindle backup restore-follower --source main --out restored.db \
  --cid 4812

One restore command, both ends: a leader’s store is its own base, so restore-follower rebuilds a leader’s store and a follower’s alike. Every snapshot the producer writes is itself a full restore of the archive, so restores are tested continuously. See Status for the one durability gap that remains.

Running It

Leader:

{
  "db": "/var/lib/rindle/leader.db",
  "posture": "authority",
  "httpPort": 7611,
  "fanoutPort": 7610,
  "bindHost": "0.0.0.0",
  "apiToken": "…",
  "adminToken": "…",
  "archive": { "store": "s3", "generation": "prod-1", "source": "main" }
}
rindle serve --config leader.json

fanoutPort is what followers tail, and a leader that serves followers needs an archive: the fan-out carries no acknowledgements by design, so the archive is the only thing that can acknowledge the log. fanoutPort without one is refused at startup rather than accepted as a degraded mode. archive.source is the name followers resume under, and it must equal their sources[0].name.

Each follower:

{
  "db": "/var/lib/rindle/follower.db",
  "httpPort": 7600,
  "bindHost": "0.0.0.0",
  "apiToken": "…",
  "adminToken": "…",
  "sources": [{
    "kind": "replicator",
    "name": "main",
    "url": "ws://leader.internal:7610/subscribe",
    "archive": { "store": "s3" }
  }]
}

kind: "replicator" names the protocol, not a process: the frames a paged leader puts on its fan-out are byte-identical to the ones the Postgres gateway puts on its, and a follower cannot tell them apart. sources[0].name must be identical on every follower of one leader — replication positions from different source names are incomparable by design, and nothing validates the string.

rindle serve --config follower.json

The edge lists the leader and the followers:

{
  "app": "main",
  "port": 7650,
  "bindHost": "0.0.0.0",
  "key": "…",
  "masterUrl": "http://leader.internal:7611",
  "followers": [
    {
      "mid": "f1",
      "region": "local",
      "wsUrl": "ws://f1.internal:7600",
      "controlUrl": "http://f1.internal:7600"
    },
    {
      "mid": "f2",
      "region": "local",
      "wsUrl": "ws://f2.internal:7600",
      "controlUrl": "http://f2.internal:7600"
    }
  ]
}
rindle edge --config edge.json

Object-storage credentials come from the standard AWS_* environment variables. Every server signals readiness to systemd (Type=notify).

Operations

  • Health. Every daemon serves /readyz, /version and /stats, and /admin/restart, /re-bootstrap and /shed behind the adminToken. Set RINDLE_METRICS_ADDR for a Prometheus /metrics listener on a third port.
  • Auth. A server bound to anything but loopback refuses to start without an apiToken.
  • TLS. Terminate it at your load balancer or proxy, in front of the edge.
  • Migrations. rindle migrate apply --url <edge> applies them on the leader. Followers receive the schema change through the log, as schema events.
  • Upgrades. Upgrade the leader first, then the followers one at a time.

Limits

  • One committer. Transactions can run concurrently on private snapshots. Their commits use one writer. The HTTP path commits each request separately. It does not batch separate requests into one log sync.
  • Manual failover. To replace a lost leader, restore its store from object storage with backup restore-follower and start a daemon on it in authority posture, pinning a new archive.generation, which fences the old lineage.