Sign inSign up

hiendt/pgpool

By hiendt

Updated 10 months ago

Image
0

313

hiendt/pgpool repository overview

PostgreSQL High Availability Cluster

Production-ready PostgreSQL 17 HA cluster với automatic failover, connection pooling, và load balancing cho Railway platform.

🐳 Docker Images

PostgreSQL Node (hiendt/postgresql-ha-cluster)

Docker Image Size

Features:

  • PostgreSQL 17 với Repmgr 5.5
  • Automatic failover (<10s)
  • Streaming replication
  • Witness node support
  • Optimized for Railway (8GB RAM, 24GB cache)

Usage:

docker run -d \
  --name postgresql-node \
  -e NODE_NAME=pg-1 \
  -e NODE_ID=1 \
  -e IS_WITNESS=false \
  -e PRIMARY_HINT=pg-1 \
  -e POSTGRES_PASSWORD=your_password \
  -e REPMGR_PASSWORD=repmgr_password \
  -e APP_READONLY_PASSWORD=readonly_password \
  -e APP_READWRITE_PASSWORD=readwrite_password \
  hiendt/postgresql-ha-cluster
Pgpool-II (hiendt/pgpool)

Docker Image Size

Features:

  • Pgpool-II v4.3.5
  • Connection pooling (max 100 children, 4 per pool)
  • Load balancing (primary weight=1)
  • Health monitoring
  • Watchdog disabled (Railway-specific)

Usage:

docker run -d \
  --name pgpool-node \
  -e POSTGRES_PASSWORD=your_password \
  -e REPMGR_PASSWORD=repmgr_password \
  hiendt/pgpool-ha-cluster
HAProxy (hiendt/haproxy-postgresql-cluster)

Docker Image Size

Features:

  • HAProxy 3.0 Alpine
  • Optimized health checks (inter 2s, rise 3, fall 2)
  • Automatic recovery from pgpool restarts
  • PostgreSQL-aware load balancing

Usage:

docker run -d \
  --name haproxy-lb \
  -p 5432:5432 \
  hiendt/haproxy-postgresql-cluster

🚀 Quick Start - Railway Deployment

Xem hướng dẫn chi tiết trong RAILWAY_DEPLOYMENT.md

Deployment Order
  1. Phase 1: Deploy stg-pg-1, stg-pg-2, stg-pg-3, stg-witness (đợi 5-10 phút)
  2. Phase 2: Deploy stg-pgpool-1, stg-pgpool-2 (đợi 3-5 phút)
  3. Phase 3: Deploy stg-haproxy-1
  4. Test: Connect qua HAProxy public URL
Environment Variables

Xem template trong .env.railway - Đổi tất cả passwords!

🏗️ Architecture

7 services: 4 PostgreSQL nodes + 2 Pgpool + 1 HAProxy

HAProxy → Pgpool (2 nodes) → PostgreSQL (1 primary + 2 standbys + 1 witness)

Components:

  • PostgreSQL 17: Database engine với streaming replication
  • Repmgr 5.5: HA management, automatic failover
  • Pgpool-II: Connection pooling & load balancing
  • HAProxy: External load balancer
  • Witness Node: Quorum cho failover decisions

🔧 Local Development

cp .env.railway .env
# Edit passwords in .env
docker-compose up -d
docker-compose logs -f

📊 Performance Specs

  • Memory: 8GB shared_buffers, 24GB effective_cache_size
  • Connections: 1000 max per PostgreSQL node
  • Failover: <10 seconds
  • Load Balancing: Primary reads enabled (weight=1)

🔒 Security

  • SCRAM-SHA-256 password encryption
  • Application users: app_readonly, app_readwrite
  • Admin users: postgres, repmgr
  • SSL disabled (Railway internal networking)

📚 Documentation

🏷️ Tags

  • latest - Latest stable release
  • v1.0.0 - Initial production release

🤝 Contributing

  1. Fork repository
  2. Create feature branch
  3. Test locally with docker-compose
  4. Submit pull request

📄 License

MIT License - see LICENSE file for details.


Built for Railway | PostgreSQL 17 + Repmgr 5.5 + Pgpool-II v4.3.5 + HAProxy 3.0

Tag summary

Content type

Image

Digest

sha256:64b636e3b

Size

48.3 MB

Last updated

10 months ago

docker pull hiendt/pgpool