Patroni: PostgreSQL high availability template
Automates PostgreSQL failover using distributed consensus systems.
Learn more about Patroni
Patroni is a high availability automation framework for PostgreSQL that manages cluster failover and replication through integration with distributed consensus systems like etcd, Consul, or ZooKeeper. It operates as a daemon running alongside each PostgreSQL instance, continuously monitoring database health and coordinating state information through the distributed configuration store to maintain a single leader topology. The framework implements automatic leader election using distributed locks, promoting standby replicas to primary when failures are detected while preventing split-brain scenarios through consensus-based decision making. Patroni dynamically reconfigures replication settings and manages PostgreSQL lifecycle operations including initialization, restart, and role transitions without manual intervention. The system supports both synchronous and asynchronous replication modes and can be deployed in containerized environments or traditional virtual machines, integrating with load balancers through REST API endpoints that expose cluster health status.
Multiple DCS backends
Supports etcd, Consul, ZooKeeper, and Kubernetes as distributed configuration stores, allowing operators to choose their existing infrastructure rather than requiring a specific consensus system.
Template architecture
Designed as a template rather than a one-size-fits-all solution, allowing customization and integration with existing PostgreSQL deployments and operational practices.
Kubernetes native support
Can run directly on Kubernetes clusters using Kubernetes as the distributed state store, with native integration for pod management and service discovery.
import requests
# Query Patroni REST API for cluster status
response = requests.get('http://localhost:8008/cluster')
cluster_info = response.json()
leader = cluster_info['members'][0]['name']
role = cluster_info['members'][0]['role']
state = cluster_info['members'][0]['state']
print(f"Leader: {leader}, Role: {role}, State: {state}")See how people are using Patroni
Top in Data Engineering
Related Repositories
Discover similar tools and frameworks used by developers
Neo4j
Open-source graph database storing data as nodes and relationships with Cypher query language.
ClickHouse
Column-oriented database for real-time analytics with SQL support and distributed computing capabilities.
PostHog
Event tracking, analytics, and experimentation platform.
dbt
SQL-based transformation framework for analytics data warehouses.
Luigi
Build complex batch pipelines with dependency management.