Figure HA-6 · Database tier
PostgreSQL high availability
Patroni elects a leader through etcd; rConfig always connects through one endpoint
rConfig
Client traffic
Replication
Health check and consensus
01 · CLIENT
rConfig
Connects to one address
02 · ENDPOINT
Database endpoint
Always points at the leader
03 · DATABASE
PostgreSQL cluster
One leader, two replicas
04 · CONSENSUS
etcd
Three members elect the leader
rConfig active node
DB_HOST = 192.0.2.30
HAProxy or VIP
192.0.2.30 · one endpoint
health check: Patroni /primary
pg1
LEADER
PostgreSQL
Patroni
accepts writes
pg2
REPLICA
PostgreSQL
Patroni
read-only, ready to promote
pg3
REPLICA
PostgreSQL
Patroni
read-only, ready to promote
etcd 1
etcd 2
etcd 3