Introduction
Pigsty is a batteries-included PostgreSQL distribution that packages HA clustering, PITR backup, monitoring dashboards, and hundreds of extensions into a cohesive platform. It turns bare metal or VMs into a production-grade database service with infrastructure-as-code provisioning.
What Pigsty Does
- Deploys PostgreSQL clusters with automatic failover using Patroni and HAProxy
- Provides point-in-time recovery via pgBackRest with configurable retention
- Includes Grafana dashboards with hundreds of pre-built PostgreSQL monitoring panels
- Bundles 460+ PostgreSQL extensions including PostGIS, TimescaleDB, and pgvector
- Manages the full infrastructure stack: DNS, NTP, CA, package repo, and observability
Architecture Overview
Pigsty uses Ansible for declarative infrastructure provisioning. A single pigsty.yml configuration file defines the entire cluster topology. The deployment includes Patroni for HA consensus, etcd as the DCS, HAProxy for connection routing, pgBouncer for connection pooling, and Prometheus/Grafana for monitoring. All components are installed from local package repos for offline capability.
Self-Hosting & Configuration
- Minimum requirement: 1 node with 2 CPU cores and 4GB RAM for single-node mode
- Multi-node HA clusters need 3+ nodes for proper failover consensus
- All configuration is declarative in pigsty.yml; re-run playbooks to apply changes
- Supports EL (Rocky, Alma, CentOS) and Debian/Ubuntu Linux distributions
- Offline installation supported via pre-downloaded package bundles
Key Features
- One-command deployment from bare metal to full production stack
- 460+ curated PostgreSQL extensions available from local repo mirrors
- Pre-built Grafana dashboards covering cluster health, query performance, and replication lag
- Built-in connection pooling via pgBouncer with configurable pool modes
- Supports 12 PostgreSQL kernel forks including Citus, IvorySQL, and PolarDB
Comparison with Similar Tools
- CloudNativePG — Kubernetes-native operator; Pigsty targets VM/bare-metal deployments with a broader infrastructure scope
- Patroni (standalone) — HA only; Pigsty wraps Patroni with monitoring, backups, extensions, and provisioning automation
- Percona Distribution — Commercial PostgreSQL bundle; Pigsty is fully open-source with more extensions and integrated monitoring
- Supabase — Full backend platform built on PostgreSQL; Pigsty focuses on database infrastructure without application-layer opinions
FAQ
Q: Can I add Pigsty to an existing PostgreSQL cluster? A: Pigsty is designed to provision from scratch. Migrating existing clusters requires pg_dump/restore or logical replication into a Pigsty-managed instance.
Q: How does failover work? A: Patroni monitors primary health and promotes a standby replica if the primary becomes unavailable. HAProxy automatically routes connections to the new primary.
Q: Can I use Pigsty in air-gapped environments? A: Yes, Pigsty supports offline installation via pre-built package bundles that include all dependencies.
Q: What PostgreSQL versions are supported? A: Pigsty supports PostgreSQL 13 through 17, with the latest version recommended for new deployments.