Navigate:
Patroni
~$PATRO0.4%

Patroni: PostgreSQL high availability template

Automates PostgreSQL failover using distributed consensus systems.

LIVE RANKINGS • 10:20 AM • STEADY
OVERALL
#224
55
DATA ENGINEERING
#10
30 DAY RANKING TREND
ovr#224
·Data#10
STARS
8.2K
FORKS
985
7D STARS
+31
7D FORKS
0
See Repo:
Share:

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.

Patroni

1

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.

2

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.

3

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

Loading tweets...


[ EXPLORE MORE ]

Related Repositories

Discover similar tools and frameworks used by developers