dev

Deploy Postgres HA

High-availability PostgreSQL cluster with Patroni, etcd, and HAProxy

Deploy Postgres HA

Postgres HA

A highly available PostgreSQL cluster using:

  • Patroni for automatic failover and cluster management
  • etcd for distributed consensus
  • HAProxy for connection routing and load balancing

Architecture

  • Postgres-1 (Primary): The primary database node
  • Postgres-2+ (Replicas): Streaming replicas for read scaling and failover
  • etcd-1/2/3 (Internal): Distributed key-value store for cluster state
  • Postgres HA (Edge): HAProxy load balancer for client connections

Connecting

Use the DATABASE_URL or DATABASE_PUBLIC_URL from the "Postgres HA" (HAProxy) service. Do not connect directly to individual Postgres nodes.

Scaling

  • Postgres replicas: Scale from 2-5 nodes using the cluster overview
  • etcd nodes: Scale from 3-7 nodes (must be odd for quorum)

Template Content