Patroni is a Python-based template for building PostgreSQL high-availability clusters. It coordinates failover using a distributed configuration store and streaming replication.
Overview
Patroni helps operators run PostgreSQL in a highly available configuration by managing leader election, failover, and cluster state. It began as an extension of earlier HA patterns and supports modern deployment styles.
The software plugs into distributed configuration stores such as ZooKeeper, etcd, Consul, Kubernetes, Exhibitor, a Python Raft implementation, or AWS-backed callbacks. You configure clusters with YAML or environment variables and can integrate Citus for distributed Postgres workloads.
Replication uses PostgreSQL streaming replication, with options for asynchronous lag limits or synchronous replication. A REST API exposes health and control endpoints, and optional HAProxy configuration offers a single application connection point.
Installation is typically via pip with optional dependency bundles for each backing store and database driver. You start member processes against configuration files alongside your chosen coordination service to form a multi-node cluster.
Key features
- PostgreSQL HA cluster management
- etcd, Consul, ZooKeeper, or Kubernetes DCS
- Streaming replication with sync or async modes
- REST API for health and control
- Optional HAProxy endpoint configuration
- YAML and environment-based configuration
- Citus extension integration
- Python Raft DCS option
Use cases
- Automated PostgreSQL failover
- Multi-node database clusters
- Kubernetes-native Postgres HA
- Application pooling through HAProxy
- Citus-aware HA deployments