Back to docs
Infrastructure

Database Replication

Horizontally scale Meridian reads across read-replica clusters with zero-downtime failover and automatic primary promotion.

Architecture

Meridian uses a single-writer, multi-reader replication topology. The primary node accepts all writes and streams WAL segments to replica nodes over TLS-encrypted connections. Replicas apply changes asynchronously with configurable lag thresholds.

Failover

When the primary becomes unreachable, the replication manager elects the most up-to-date replica using a Raft consensus protocol. Promotion completes in under 3 seconds. The old primary is fenced via STONITH to prevent split-brain writes.

Connection Routing

Meridian's proxy layer inspects SQL statements to route reads to replicas and writes to the primary. Applications connect to a single endpoint — the proxy handles topology changes transparently.

Monitoring

Replication lag, throughput, and node health are exposed via Prometheus metrics. Alerting thresholds trigger when lag exceeds 500ms or any node drops from the quorum.