Keep MQTT state across restarts
By default, retained messages, persistent sessions, and queued QoS 1/2 traffic live in memory. A broker restart clears them. Durability writes that state to a local write-ahead log (WAL) so after a restart, clients can reconnect and pick up where they left off — their subscriptions, retained values, and any messages that were still waiting to be delivered.When to enable durability
Enable durability when you need:- retained values to survive a broker restart;
- persistent sessions and their subscriptions restored after reboot; or
- queued QoS 1/2 messages re-offered to clients that reconnect with a persistent session.
Durability is a broker-level setting. It works on a standalone broker and on every cluster node. In a high-availability cluster (beta), enable it on every node: it keeps each node’s sessions and queued messages across restarts, and it lets subscriptions follow a client that reconnects to another node.
Configure the
Durability section (or COREFLUX_DURABILITY_* environment variables), restart the broker, and verify retained or session state after a controlled restart.
Quick Start
Add aDurability block to the broker configuration, or set environment variables (env vars override the file). Restart the broker for changes to take effect.
- Enable (typical)
- Strongest fsync
- Environment variables
Opt in with the default flush policy (group commit every 50 ms):
What is persisted
QoS 0 traffic is not made durable by this layer — MQTT treats it as best-effort.
Configuration reference
Accept
1 / true (case-insensitive) for COREFLUX_DURABILITY_ENABLED.
Fsync policy
Codec
json(default) — human-readable records; easier to inspect during debugging.binary— compact encoding; smaller on disk and typically faster to encode/decode on busy brokers. Existing JSON segments still recover; new records append in binary. Switching back from binary tojsonfor inspection of already-written binary segments is not supported — stay onjsonif you need text tooling on the log.
Performance
Durability is built so that you only pay for the state you choose to protect.
In our tests with the default flush policy (one broker, QoS 1), average round-trip latency was unchanged, and fan-out to 20 persistent subscribers kept about two-thirds of the delivery rate it reached with durability off.
FsyncPolicy: always waits for the disk on every write and is meant for low message rates.
Durability and clustering
Durability and clustering (beta) protect different parts of a message’s path, and a cluster needs both:
Without durability, a cluster node that restarts comes back with no sessions. Messages that the other nodes kept for its persistent subscribers then have no session to go to, and are lost. See Durability and clustering on the clustering page.
Observability
Prometheus/metrics exposes durability and WAL series, including:
Use these alongside your usual broker health checks after enabling durability or changing fsync policy.
Limitations
Next Steps
High-Availability Clustering
Run multiple brokers with quorum replication and session failover on top of durability.
Broker Configuration
Ports, TLS, listeners, and other broker settings.

