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.
Related Reading
Guides and comparisons from the Greptile content library
Top AI Code Review Tools for Small Dev Teams 2026
Affordable, lightweight AI code review tools that help small teams catch bugs faster. Practical comparisons of accuracy, ease of use, and value for teams without enterprise budgets.
Guide to Self-Hosted AI Code Review for GitLab and GitHub Enterprise [2026]
How self-hosted AI code review works on GitLab Self-Managed and GitHub Enterprise Server, how it compares to SaaS review tools, what to look for in a self-hosted tool, and what a self-hosted rollout actually takes.
What is Source Code Management (SCM): Everything Engineering Leaders Need to Know
Source code management is more than branching and merging. Here is how SCM works, the top tools, the best practices, and why good code review is the foundation of source control in an agentic era.
Best AI Coding Tools for Solo Developers (2026 Review)
The best AI coding tools for solo developers in 2026, compared by where they fit in the software development lifecycle: writing code, prototyping, reviewing, testing, and background automation. Plus which tools fit which languages.