# Stolon — Cloud-Native PostgreSQL High Availability Manager > Stolon is a cloud-native PostgreSQL high-availability manager written in Go. It uses a distributed consensus store (etcd, Consul, or Kubernetes API) to coordinate automatic failover, synchronous replication, and proxy routing for PostgreSQL clusters. ## Install Save as a script file and run: # Stolon — Cloud-Native PostgreSQL High Availability Manager ## Quick Use ```bash # Initialize a new cluster with etcd as the store stolonctl --cluster-name mycluster --store-backend etcd3 init # Start the sentinel (monitors and manages failover) stolon-sentinel --cluster-name mycluster --store-backend etcd3 # Start a keeper (manages a PostgreSQL instance) stolon-keeper --cluster-name mycluster --store-backend etcd3 --pg-listen-address 0.0.0.0 # Start the proxy (routes client connections) stolon-proxy --cluster-name mycluster --store-backend etcd3 --listen-address 0.0.0.0:5432 ``` ## Introduction Stolon provides automated high availability for PostgreSQL by coordinating sentinels, keepers, and proxies through a distributed store. It handles leader election, automatic failover, and streaming replication so PostgreSQL clusters can survive node failures without manual intervention. ## What Stolon Does - Manages PostgreSQL high availability with automatic leader election and failover - Coordinates cluster state through etcd, Consul, or the Kubernetes API - Routes client connections to the current primary through a smart proxy component - Configures and maintains streaming replication between primary and standbys - Supports synchronous replication for zero-data-loss failover scenarios ## Architecture Overview Stolon has three components: the Sentinel monitors cluster health and decides failover actions, the Keeper manages the local PostgreSQL instance (starting, stopping, promoting, and configuring replication), and the Proxy routes client connections to the current primary. All components coordinate through a distributed key-value store, making the system resilient to network partitions and component failures. ## Self-Hosting & Configuration - Deploy etcd, Consul, or use the Kubernetes API as the cluster store backend - Run at least two Sentinels for high availability of the management layer - Run one Keeper per PostgreSQL instance, each with its own data directory - Deploy Proxies on application nodes or as a service for connection routing - Use stolonctl to initialize the cluster and manage configuration changes ## Key Features - Automatic failover with configurable timeout and fencing policies - Supports both asynchronous and synchronous streaming replication - Kubernetes-native deployment with Helm charts and StatefulSet patterns - Point-in-time recovery integration with backup tools like WAL-G and Barman - Declarative cluster specification managed through stolonctl update ## Comparison with Similar Tools - **Patroni** — Similar HA manager with more community adoption; Stolon offers a separate proxy component for connection routing - **CloudNativePG** — Kubernetes-native operator approach; Stolon works on bare metal and VMs as well - **pgBouncer + repmgr** — Manual HA setup requiring more operational glue; Stolon automates the full stack - **Crunchy PGO** — Commercial Kubernetes operator; Stolon is fully open source under Apache 2.0 - **pg_auto_failover** — Simpler architecture with a monitor node; Stolon uses distributed consensus for stronger fault tolerance ## FAQ **Q: Can Stolon run outside of Kubernetes?** A: Yes. Stolon supports etcd and Consul as store backends for bare-metal and VM deployments. **Q: How fast is automatic failover?** A: Failover typically completes within seconds, depending on the configured health check interval and timeout. **Q: Does Stolon support read replicas for load balancing?** A: The proxy routes to the primary only. Read replicas can be accessed directly for read-only workloads. **Q: Is Stolon still actively maintained?** A: The project receives updates periodically and has a stable feature set suitable for production use. ## Sources - https://github.com/sorintlab/stolon - https://github.com/sorintlab/stolon/blob/master/doc/architecture.md --- Source: https://tokrepo.com/en/workflows/asset-18fff472 Author: Script Depot