Skip to content
Guides & References

PostgreSQL high availability for rConfig

Make rConfig's PostgreSQL database highly available with Patroni or repmgr, a VIP or HAProxy in front, and the right replication mode for your RPO.

High AvailabilityUpdated
On this page

PostgreSQL high availability for rConfig

PostgreSQL holds rConfig’s devices, encrypted credentials, tasks, policies, users, compliance history and audit trail. rConfig connects to one endpoint and needs it to always reach the primary. This page covers the common ways to keep PostgreSQL available, and the choices that decide how much data a failover can lose. PostgreSQL is available on rConfig Enterprise.


What rConfig needs from the database tier

  • One endpoint in DB_HOST that always reaches the current primary. rConfig doesn’t split reads and writes, and doesn’t know about replicas.
  • Failover without a change to rConfig. The HA tooling promotes a replica and moves the endpoint; rConfig reconnects to the same address.
  • A replica sized like the primary, because after failover it carries the full load.

The common designs

Design How failover works Endpoint for rConfig Fits
Patroni with etcd Patroni on each database node elects a leader through etcd and promotes a replica when the leader fails A VIP that follows the leader (vip-manager or keepalived checking Patroni’s REST API), or HAProxy routing to the leader Automatic failover with strong split-brain protection. The usual choice
repmgr repmgrd monitors the primary and promotes a replica A VIP moved by repmgr’s event scripts, or HAProxy Teams that prefer fewer moving parts than Patroni and etcd
Managed PostgreSQL (Amazon RDS or Aurora, Azure Database for PostgreSQL, Google Cloud SQL) The provider fails over to a standby in another zone The provider’s endpoint, unchanged after failover Cloud deployments
Figure HA-6: the active rConfig node connects through HAProxy or a VIP at 192.0.2.30 to the Patroni leader pg1, which streams to replicas pg2 and pg3, with three etcd members providing consensus
Figure HA-6: PostgreSQL high availability with Patroni. rConfig always connects through one endpoint. Click the diagram to open the interactive version.

Patroni needs an odd number of etcd members (three is typical), ideally on separate hosts or failure domains from each other, so the cluster can always form a majority.


Synchronous or asynchronous replication

Mode RPO Cost
Asynchronous Can lose the last transactions not yet replicated (usually seconds) No effect on write speed
Synchronous (Patroni synchronous_mode) Committed transactions are on at least one replica Every write waits for a replica; a replica outage can stall writes unless a second replica is available

For rConfig, asynchronous replication with low lag is often enough: a lost download can be collected again at the next backup. Choose synchronous replication when the RPO says rConfig must not lose committed changes, such as audit history, and run at least two replicas so one can fail without stalling writes.


HAProxy in front

HAProxy routes rConfig’s connections to whichever node Patroni reports as leader, using Patroni’s REST API as the health check (GET /primary returns 200 only on the leader). Run HAProxy itself on both rConfig nodes, or behind its own VIP, so it isn’t a new single point of failure.

haproxy.cfg (excerpt)
listen rconfig_postgres
bind 192.0.2.30:5432
option httpchk GET /primary
http-check expect status 200
default-server inter 3s fall 3 rise 2 on-marked-down shutdown-sessions
server pg1 192.0.2.31:5432 check port 8008
server pg2 192.0.2.32:5432 check port 8008
server pg3 192.0.2.33:5432 check port 8008

on-marked-down shutdown-sessions closes rConfig’s connections to the old primary straight away, so they reconnect to the new one instead of hanging.


Operating it

  • Watch replication lag. With asynchronous replication, lag is the data you’d lose.
  • Back up independently. Replication copies a dropped table to every replica in seconds. Keep rConfig’s own backups and PostgreSQL backups (pgBackRest or similar).
  • Test failover by stopping the primary during a quiet period, and check rConfig recovers without intervention.

Type to search.