PostgreSQL
3 minutes

PostgreSQL + Patroni

High-availability PostgreSQL clusters

Deploy a high-availability PostgreSQL cluster with Patroni for automatic failover, etcd for distributed consensus, PgBouncer for connection pooling, and HAProxy for read/write splitting. Includes pgBackRest for automated backups and cross-region read replicas. A production-ready, self-hosted alternative to AWS RDS.

High Availability with Patroni

Patroni provides automatic failover and leader election for your PostgreSQL cluster, ensuring zero-downtime operations.

  • Automatic failover: Detects primary node failures and promotes a replica within seconds
  • etcd coordination: Uses etcd for distributed consensus and leader election
  • Health monitoring: Continuous health checks and automatic recovery
  • Minimum 3 nodes: Deploy 3-7 nodes for optimal quorum and performance

PgBouncer Connection Pooling

PgBouncer manages database connections efficiently, reducing overhead and improving performance.

  • Connection pooling: Reuses connections to reduce database load
  • Transaction pooling: Efficient handling of short-lived connections
  • Per-database configuration: Fine-tune pooling settings per database

HAProxy Read/Write Splitting

Optional HAProxy instances provide intelligent routing between read and write operations.

  • Writer endpoint: Routes all writes to the current primary node
  • Reader endpoint: Distributes reads across all replicas for load balancing
  • Automatic failover: Updates routing automatically when primary changes
  • Health checks: Monitors node health and routes traffic accordingly

pgBackRest Backups

Integrated backup and restore using pgBackRest, providing fast and reliable backups.

  • Full and incremental backups: Efficient backup strategies for large databases
  • Point-in-time recovery: Restore to any point in time from backup history
  • S3-compatible storage: Store backups in S3-compatible storage
  • Parallel backup/restore: Fast backup and restore operations

Cross-Region Read Replicas

Deploy read replicas in different geographical regions for faster reads and disaster recovery.

  • Geo-distributed reads: Serve reads from the closest region for lower latency
  • Automatic replication: Streaming replication keeps replicas in sync
  • Independent scaling: Scale read capacity independently in each region
  • Disaster recovery: Replicas can be promoted to primary in case of region failure

Visual Config Editor

Customize your PostgreSQL and Patroni configuration without editing raw YAML files. Our visual config editor layers your customizations on top of battle-tested defaults.

  • Pre-configured defaults: Start with production-ready settings tuned for performance
  • Override anything: Add custom settings that merge with our defaults
  • No config conflicts: Your changes apply cleanly without breaking core functionality
  • Version controlled: Track configuration changes across deployments

Why Self-Host

Why Self-Host PostgreSQL + Patroni?

Skip the markup. Deploy on your own servers and save 60-90% compared to AWS RDS.

Self-hosting gives you

  • Save 60-80% compared to AWS RDS Multi-AZ pricing
  • No hidden charges for IOPS, data transfer, or snapshot storage
  • Full PostgreSQL configuration access — no restricted parameters
  • SSH access to your servers for debugging and custom extensions
  • No vendor lock-in — migrate between providers without downtime

Cost comparison vs AWS RDS

SetupAWS RDSSelf-Hosted
Starter (3 nodes, 8GB RAM)$400-600/mo$60/mo
Growth (3 nodes, 32GB RAM)$1,200-1,800/mo$100/mo
Scale (3 nodes, 64GB RAM)$3,000-5,000/mo$180/mo

Self-hosted prices based on Hetzner dedicated servers. Managed prices based on AWS RDS Multi-AZ with storage and IOPS.

FAQ

Frequently Asked Questions

Common questions about this deployment recipe.

Simple, one-time pricing

Pay once, get free updates for a year. After that, pay again to continue receiving updates.

50 spots remaining

$199$299

One-time payment • Free updates for 1 year

  • All database recipes (and upcoming recipes)
  • Unlimited servers
  • All cloud providers
  • Server hardening
  • Monitoring stack
  • AI-powered diagnostics
  • Cross-region replicas
  • Free updates for 1 year
Get sshploy now

After 1 year, pay again to continue receiving updates