QuestDB Replication & Distributed Mode: WAL Object-Store Replication, Failover, and Read Scaling
A single QuestDB node writes fast and queries fast, but production raises three questions: what happens when a node dies? what happens when query load climbs? how do we replay history to an arbitrary instant? QuestDB’s high availability is two layers, and a resilient deployment usually needs both: server-side replication keeps the cluster alive through a lost node (an Enterprise feature, the subject of this post), and client-side resilience keeps your applications connected and lossless across the failover that replication makes possible. Replication moves the data; the client-side features make the applications follow it.
1. Architecture: primary writes WAL → object store → replicas pull
primary ──uploads WAL segments──▶ object store (S3 / Azure Blob / GCS / NFS) ──replicas poll & download──▶ replica 1..N
The primary writes to a local Write Ahead Log (WAL), then uploads compressed WAL segments to an object store; each replica periodically polls, downloads, and replays those segments, staying hot. Decoupling through an object store buys several practical properties:
- Replicas scale out or in without touching the primary; replicas have zero performance impact on the primary (documented explicitly).
- Replicas live in other regions or AZs, close to readers.
- The object store doubles as the recovery medium — every WAL segment is there, enabling point-in-time recovery.
- Supported stores today: AWS S3, Azure Blob Storage, Google Cloud Storage, NFS; HDFS is planned.
The role switch happens at runtime: a single SWITCH ROLE SQL statement promotes a replica in place — neither node restarts. Hot-availability strategies recover by promoting a replica; cold strategies rebuild a fresh primary from the latest snapshot plus WAL files — slower, cheaper.
2. Minimal configuration
Two settings on every node’s server.conf:
# primary
replication.role=primary
replication.object.store=s3::bucket=questdb-wal;region=ap-northeast-1;access_key=...;secret_key=...
# replica
replication.role=replica
replication.object.store=<same store, its own credentials string>
replication.replica.poll.interval=1000 # ms, default 1s
replication.object.store is a scheme::key1=value;key2=value connection string; the full key set per provider lives on the Replication configuration page.
3. Runtime role switching — and the restart trap you must remember
SWITCH ROLE (Enterprise 3.3.3+) changes the running role; it does not update server.conf. The official docs put a danger-level warning here, worth memorizing:
- a node demoted to replica that restarts with
replication.role=primarycomes back as a second primary on the same object store — data starts to fork; - a node promoted to primary that restarts with
replication.role=replicasilently demotes itself — you think you have a primary, you don’t.
The procedure is therefore: after any SWITCH ROLE, edit both nodes’ server.conf to the new roles before either node is allowed to restart. For a planned migration (move the primary to another machine), the one-shot primary-catchup-uploads mode exists: the node boots as primary, uploads every pending transaction, and exits; then you switch config and restart.
4. Which tables actually replicate — the exceptions
Replication applies to WAL-enabled tables — tables with a designated timestamp and a partitioning scheme, i.e. the bulk of time-series workloads. Two exceptions you must handle yourself:
- Tables without timestamps (reference/lookup tables) are not replicated. Populate them on every instance separately, or route them elsewhere.
replication.disabled.tablestakes specific tables out of replication (comma-separated, reloadable — no restart): the primary stops uploading their WAL and replicas stop downloading it.
Audit nuance: for sys.view_audit, the table definition and storage policy replicate, but the rows do not — each node records the reads it serves. sys.acl_audit_log (Enterprise 4.2.1+) replicates definition and rows; a replica promoted before it received the table creates it from its own acl.audit.storage.policy, so set that property on every node before upgrading.
5. The client layer: failover + store-and-forward
Server-side replication makes the cluster survive a lost node; the client features make your applications follow along:
- Client failover: a client walks a configured host list when its connection breaks, so a primary promotion is transparent to it.
- Store-and-forward: unacknowledged writes buffer locally; a producer survives the outage without losing data and flushes on recovery.
Both are available to all native clients — no Enterprise license required on the client side.
6. Storage policies & cold storage inside a replicated cluster
Storage policies (TO PARQUET / DROP LOCAL TTLs) live in WAL-backed system tables, so the policy definitions replicate to every node through the same WAL pipeline. Enforcement, however, runs independently on each instance: Parquet files are produced locally, and each node schedules its own PARQUET_CONVERT/PARQUET_COMMIT/DROP_LOCAL jobs. At any moment the primary and a replica can hold a partition in different states (converted on the primary, still native on a replica that hasn’t hit its check interval) — temporary, and the cluster converges once each node’s check job runs. Tune storage.policy.check.interval and storage.policy.worker.count per node to trade conversion latency against background load.
Cold storage is stricter: one manager instance uploads partitions, writes manifests, and runs remote garbage collection; every other instance is a refresher mirroring that state read-only. The manager role is independent of primary/replica — all four combinations are valid, and running the manager on a replica moves the upload and GC work off the primary.
7. Sizing & selection notes
- The object store is the hub of the whole replication path and your recovery medium. NFS is fine for test environments; production wants a cloud object store. Note: from Enterprise 4.2.1, an S3-compatible store must support (or ignore) the
If-Match/If-None-Matchheaders onPutObject, or a primary cannot start or be promoted. - The tuning knobs:
cairo.wal.segment.rollover.size(default 2 MiB),replication.primary.compression.level(zstd 1–22, default 1),replication.primary.sequencer.part.txn.count(default 5000 — smaller is kinder to narrow links but more costly), and the replica poll interval. - Multi-master (several nodes writing the same table) is a more advanced enterprise topology discussed in QuestDB’s “Inner Workings of Distributed Databases” blog post — read it before touching a production deployment.
- Operations: self-managed, or QuestDB’s team operating it on your infrastructure under BYOC (your CloudFormation/Lighthouse-managed infrastructure, fully yours to audit).
Next steps
- A replica refuses to promote (refused switch): the failover doc has a dedicated section.
- Client failover and store-and-forward parameters: their own concept pages.
- Point
sys.metricsat Grafana so replication lag (primary upload vs replica apply) is a line on a dashboard.