IT lexicon › Database › Patroni

Patroni

Database På svenska → Updated: 2026-07-29

The template for highly available PostgreSQL. A Python agent that runs alongside each database node and handles primary election and automatic failover. Built by Zalando.

The hard part of automatic failover is deciding who is primary without risking two primaries at once. Patroni solves it by putting the truth outside the database, in a distributed configuration store — etcd, Consul, ZooKeeper or Kubernetes' own API server. Whichever node holds a time-limited leader lock is primary; if it loses the lock it demotes itself before anyone else can take over. The agent also writes postgresql.conf and pg_hba.conf, bootstraps new replicas and exposes a REST API that load balancers can query to find out who takes writes. In practice the default choice, and the foundation of most Postgres operators for Kubernetes.

← Back to the lexicon