Pgpool-II architecture, pgpool.conf reference & PgBouncer comparison.
Pgpool-II
SQL Router & Watchdog (:9999 / :9898)
SQL Load Balancer
recommendedParses PostgreSQL wire-protocol queries to send writes, `SELECT ... FOR UPDATE`, and volatile functions to the primary while balancing safe SELECTs across standbys.
Pre-Forked Child Pool
recommendedPre-forks `num_init_children` worker processes, each caching up to `max_pool` `(user, database)` backend sockets.
Watchdog VIP Quorum
supported3-node active/standby Pgpool-II consensus ring managing a floating Virtual IP (`delegate_ip`) and preventing split-brain failovers.
PCP Online Recovery
supportedTwo-stage online standby rebuild using `pg_basebackup` and `pcp_attach_node` without interrupting primary traffic.
We manage Pgpool-II 4.4/4.5 clusters and execute Pgpool-to-PgBouncer/Patroni modernizations.
- P1: 15 min · P2: 30 min
- SLA response times, 24/7 (P3: 60 min). Response means an on-call engineer is working the incident.
- Capacity Invariant
- (num_init_children * max_pool) <= (PostgreSQL max_connections - superuser_reserved_connections).
- Pgpool vs PgBouncer
- Choose Pgpool-II for single-port SQL read/write splitting; choose PgBouncer for 10,000+ connection transaction multiplexing.
Selected clients
Production Failure Modes
Six Pgpool-II failure modes we resolve in production.
Pgpool-II combines four jobs in one daemon (pooling, SQL routing, failover, and VIP management). Misconfiguring child-process math or Watchdog quorum causes immediate production stalls.
PostgreSQL rejects connections with `FATAL: sorry, too many clients already`
num_init_children * max_pool exceeds max_connections
`num_init_children` was set to 200 and `max_pool` was left at the default 4 (`200 * 4 = 800` potential backend sockets per PostgreSQL node) while PostgreSQL `max_connections` is only 300.
Enforce `(num_init_children * max_pool) <= (max_connections - superuser_reserved_connections)` in `pgpool.conf`; lower `max_pool` to 1 or 2 when serving a single app user/database pair.
New client connections hang at TCP connect despite idle PostgreSQL CPU
All num_init_children processes occupied by idle clients
Unlike PgBouncer's event loop, Pgpool-II binds one client session to one pre-forked child process until the client disconnects (`process-per-client` model),unless `serialize_accept` and `client_idle_limit` are tuned.
Set `client_idle_limit`, enable `serialize_accept = on` to avoid thundering-herd `accept()` lock contention, or place lightweight PgBouncer in front of Pgpool-II.
Read-after-write queries return stale data inside or right after transactions
SELECT routed to standby before WAL replay
`disable_load_balance_on_write` is set to `transaction` only, allowing a subsequent transaction on the same connection to hit a lagged standby before WAL replay catches up.
Set `disable_load_balance_on_write = 'trans_transaction'` (or `'dml_adaptive'`) and configure `delay_threshold_by_time = 2000ms` using `sr_check_period`.
Healthy standby gets marked `down` (`status 3`) during brief network jitter
pcp_node_info reports status = 3 (down)
`health_check_max_retries` and `health_check_retry_delay` are too aggressive, causing a transient packet drop to trigger `failover_command` or detach the standby.
Tune `health_check_period = 5`, `health_check_timeout = 10`, `health_check_max_retries = 3`, `health_check_retry_delay = 2`, and enable `auto_failback = on`.
Two Pgpool-II nodes both claim the Virtual IP (`delegate_ip`) on network split
ARP conflict on delegate_ip / split-brain failover
Watchdog was deployed with an even number of Pgpool-II nodes (2 nodes) without `enable_consensus_with_half_votes = off` or an external pingable gateway (`trusted_servers`).
Deploy a 3-node Pgpool-II Watchdog ring, configure `trusted_servers` so isolated nodes release `delegate_ip`, and set `failover_when_quorum_exists = on`.
Volatile functions (`nextval()`, `random()`, custom stored procs) hit standbys
ERROR: cannot execute nextval() in a read-only transaction
Custom PostgreSQL functions that mutate rows or sequences inside a `SELECT my_mutating_func()` call are not listed in `black_function_list` / `write_function_list`.
Populate `write_function_list` in `pgpool.conf` (or mark functions properly as `VOLATILE` in `pg_proc` with `check_unlogged_table = on`) so Pgpool-II routes them strictly to the primary.
Response SLA & Incident Triage
SLA response times and the first hour of a P1.
When `SHOW POOL_NODES` reports a detached node (`status 3`) or child workers lock up, you reach a senior PostgreSQL DBRE directly.
15 mins
Response SLA
P1 response SLA: 15 mins, 24/7.
30 mins
Response SLA
P2 response SLA: 30 mins, 24/7.
60 mins
Response SLA
P3 response SLA: 60 mins, 24/7.
SLA response times by severity (24/7)
Production database down, primary unreachable, data corruption risk, or active failover event.
Severe latency spike, replication lag climbing rapidly, connection exhaustion, or degraded HA node.
Non-critical slow query regression, staging issue, backup warning, configuration question, or planned operational request.
Our engineering team is in India (IST, UTC+5:30) and provides 24/7 support. Response means an on-call engineer is working the incident, not an automated reply.
01 · Page
0 to 15 minutes (P1 response SLA)
Your alert reaches a senior PostgreSQL/Pgpool-II DBRE directly, with no Tier-1 ticket triage queue.
02 · Triage
15 to 30 minutes
We run `SHOW POOL_NODES;`, `SHOW POOL_PROCESSES;`, and `pcp_watchdog_info` to check node states (`up`, `down`, `waiting`), Watchdog quorum, and child-process saturation.
03 · Mitigate
30 to 60 minutes
We reattach healthy standbys via `pcp_attach_node`, trigger online recovery (`pcp_recovery_node`), or reload `pgpool.conf` child/timeout settings to clear connection stalls.
04 · Review
Within 24 hours
We deliver a written post-incident finding with corrected `num_init_children * max_pool` math, Watchdog quorum rules, and Prometheus `pgpool2_exporter` alerts.
Architecture & Operational Scope
Six Pgpool-II subsystems we architect and manage.
Whether you are optimizing an established Pgpool-II 4.5 cluster or evaluating a transition to PgBouncer + Patroni, we cover every technical detail.
SQL-Aware Single-Port Read/Write Splitting
Route writes and reads over a single connection string (:9999) without modifying legacy application code to use separate read and write pools.
- `disable_load_balance_on_write = 'trans_transaction'` for read-your-own-writes consistency.
- `write_function_list` and `statement_level_load_balance` tuning for complex stored procedures.
Child Process & Connection Pool Sizing
Calibrate `num_init_children`, `max_pool`, and `process_management_mode = dynamic` (Pgpool-II 4.4+) so backend limits never breach `max_connections`.
- Dynamic process sparing (`min_spare_children`, `max_spare_children`) in Pgpool-II 4.4/4.5.
- Elimination of `accept()` thundering herd via `serialize_accept = on`.
3-Node Watchdog VIP & Quorum Fencing
Deploy a fault-tolerant 3-node Pgpool-II Watchdog cluster with a floating Virtual IP (`delegate_ip`) and quorum-gated failover.
- `failover_when_quorum_exists = on` and `failover_require_consensus = on`.
- `trusted_servers` upstream reachability validation to prevent isolated VIP claims.
Automated Failover & `pcp_recovery_node`
Script deterministic `failover_command`, `follow_primary_command`, and one-command online standby rebuilding via PCP.
- Automatic standby cascade re-pointing (`follow_primary_command`) when a new primary promotes.
- Online standby provisioning using `pcp_recovery_node` and `pg_basebackup`.
Pgpool-II vs PgBouncer + HAProxy Migration
Benchmark whether your workload belongs on Pgpool-II or a decoupled PgBouncer + HAProxy + Patroni stack, and execute the migration cleanly.
- Side-by-side latency and CPU profiling at 5,000 to 50,000 QPS.
- Staged transition from Pgpool-II Watchdog to Patroni + PgBouncer where appropriate.
In-Memory Query Cache & Telemetry
Configure shared-memory or Memcached query caching (`memory_cache_enabled`) and Prometheus `pgpool2_exporter` monitoring.
- Automatic table-OID cache invalidation on `INSERT`/`UPDATE`/`DELETE` commits.
- Grafana dashboards tracking `SHOW POOL_NODES`, `SHOW POOL_CACHE`, and replication delay.
Interactive Pool States & Reference pgpool.conf
How Pgpool-II handles load balancing, child sizing, and PCP recovery.
Compare healthy 3-node Watchdog load balancing, a `num_init_children * max_pool` overflow incident, and an automated failover with `pcp_recovery_node`, followed by our reference `pgpool.conf`.
Pgpool-II Watchdog & Child Process Pool Simulator
Application and routing
3-node Pgpool-II Watchdog cluster holds `delegate_ip` on pgpool-1; `SHOW POOL_NODES` reports Node 0 (`primary`) and Nodes 1-2 (`standby`) with <50 ms delay.
Pgpool-II 4.5 Watchdog (x3)
VIP 10.0.6.100:9999 · SQL Parser
failover_when_quorum_exists = on
Node 0 · pg-1 (primary, status 2)
Receives writes & trans_transaction reads
lb_weight = 0.2 · 0 delay
Nodes 1 & 2 · pg-2/pg-3 (standby, status 2)
Serve load-balanced SELECT queries
lb_weight = 0.4 each · auto_failback = on
3-node Pgpool-II Watchdog cluster holds `delegate_ip` on pgpool-1; `SHOW POOL_NODES` reports Node 0 (`primary`) and Nodes 1-2 (`standby`) with <50 ms delay.
Application and routing
`num_init_children = 250` and `max_pool = 4` attempts to open up to 1,000 PostgreSQL backends on a server with `max_connections = 300`, triggering connection failures.
Application Pods
Open connections across 3 DB users
Each user creates a separate max_pool slot
Pgpool-II Child Workers (250)
Cache up to 4 (user,db) sockets each
250 * 4 = 1,000 sockets per PG node
PostgreSQL Primary & Standbys
Reject connections above 300
FATAL: sorry, too many clients already
`num_init_children = 250` and `max_pool = 4` attempts to open up to 1,000 PostgreSQL backends on a server with `max_connections = 300`, triggering connection failures.
Application and routing
When Node 0 fails, Watchdog promotes Node 1 to primary, re-points Node 2 via `follow_primary_command`, and rebuilds Node 0 online using `pcp_recovery_node`.
Node 1 · pg-2 (Promoted Primary)
failover_command promotes pg-2
Accepts writes via VIP :9999
Node 2 · pg-3 (Cascaded Standby)
follow_primary_command runs pg_rewind
Streams WAL from Node 1
Node 0 · pg-1 (Rebuilt Standby)
pcp_recovery_node stages 1 & 2 complete
Auto-attached as status 2 (up)
When Node 0 fails, Watchdog promotes Node 1 to primary, re-points Node 2 via `follow_primary_command`, and rebuilds Node 0 online using `pcp_recovery_node`.
Production Configuration Specimen · Pgpool-II 4.5
Right-Sized pgpool.conf & PCP Online Standby Recovery Runbook
1. Reference /etc/pgpool-II/pgpool.conf
/etc/pgpool-II/pgpool.conf
# /etc/pgpool-II/pgpool.conf (Pgpool-II 4.5 Reference) listen_addresses = '*' port = 9999 pcp_listen_addresses = '127.0.0.1' pcp_port = 9898 # 1. Process & Connection Pool Sizing: (120 * 2) = 240 <= (max_connections 300 - 10) process_management_mode = dynamic num_init_children = 120 min_spare_children = 10 max_spare_children = 30 max_pool = 2 serialize_accept = on client_idle_limit = 300 # 2. Streaming Replication & Read-Your-Own-Writes Consistency backend_clustering_mode = 'streaming_replication' load_balance_mode = on disable_load_balance_on_write = 'trans_transaction' sr_check_period = 2 delay_threshold_by_time = 2000ms # 3. Health Checks & Quorum-Gated Failover health_check_period = 5 health_check_timeout = 10 health_check_max_retries = 3 health_check_retry_delay = 2 failover_when_quorum_exists = on failover_require_consensus = on auto_failback = on # 4. 3-Node Watchdog & Floating VIP use_watchdog = on delegate_ip = '10.0.6.100' trusted_servers = '10.0.6.1'
2. Operator PCP & SHOW POOL_NODES commands
PCP (:9898) & SQL (:9999) Operations
# 1. Inspect node IDs, statuses (up/down), roles (primary/standby), and replication delay psql -h 10.0.6.100 -p 9999 -U postgres -c "SHOW POOL_NODES;" # 2. Check Watchdog cluster quorum and VIP holder status pcp_watchdog_info -h 127.0.0.1 -p 9898 -U pgpool_admin -w # 3. Gracefully detach Node 2 for planned maintenance pcp_detach_node -h 127.0.0.1 -p 9898 -U pgpool_admin -w -g -n 2 # 4. Rebuild and reattach a failed standby (Node 0) online from the current primary pcp_recovery_node -h 127.0.0.1 -p 9898 -U pgpool_admin -w -n 0
Shared Responsibility & Platforms
What your team owns and what JusDB owns.
Managed cloud databases automate much of the infrastructure layer, but your team still owns query performance, capacity, cost, and incident decisions. We manage Pgpool-II across bare-metal Linux, VMware, AWS EC2, GCP Compute Engine, Azure VMs, and Kubernetes.
| Operational Layer | Customer Team | JusDB DBRE Team |
|---|---|---|
| Application SQL & Function Volatility | Connect apps to Pgpool-II VIP (:9999) and declare mutating functions | Audit SQL traffic, populate `write_function_list`, and configure `disable_load_balance_on_write` |
| `pgpool.conf` & Child Pool Math | Approve maintenance windows and infrastructure PRs | Calculate `num_init_children`, `max_pool`, and `process_management_mode` against `max_connections` |
| Watchdog VIP & Failover Scripts | Provide 3 proxy VMs and `/sbin/ip` `CAP_NET_ADMIN` or sudoers permissions | Author `failover.sh`, `follow_primary.sh`, and `escalation.sh` with quorum safeguards |
| PCP Online Recovery (`pcp_recovery_node`) | Allow SSH/replication traffic between PostgreSQL data nodes | Configure `recovery_1st_stage` scripts and test single-command standby rebuilds |
| 24/7 Telemetry & Incident Response | Receive Slack/PagerDuty notifications on SLA events | Monitor `SHOW POOL_NODES`, `pgpool2_exporter`, and respond within the response SLA |
Customer Boundary
What stays in your control
- Set business priorities, application requirements, and release plans
- Approve production changes, except routine actions you have pre-approved
- Own your cloud accounts, access policies, and vendor relationships
- Decide when maintenance can happen and how quickly service must recover
- Move the work in-house or to another provider after your agreement's notice period, with your data returned or deleted and the transition help your agreement sets out (Terms, section 8)
JusDB Execution Scope
What our DBREs execute for you
- Monitor database health, investigate alerts, and involve the right people
- Review query performance, replication, capacity, and backup health
- Carry out approved changes and update the operating instructions they affect
- Report completed work, open risks, and recommended next steps
Pgpool-II vs PgBouncer & Engagement Paths
Pgpool-II vs alternatives and how to engage JusDB.
Compare Pgpool-II against PgBouncer, Odyssey, and HAProxy across pooling architecture, SQL load balancing, and Watchdog HA, then choose how to engage our PostgreSQL DBRE team.
| Evaluation Vector | JusDB Pgpool-II DBRE | PgBouncer / HAProxy | Direct / In-House |
|---|---|---|---|
| Query Inspection & Read/Write Splitting | Intelligent SQL parsing routes SELECT to read replicas and INSERT/UPDATE/DELETE to primary without application code changes or dual connection pools | PgBouncer does no SQL parsing; HAProxy requires dual listening ports and application-level routing logic across distinct database endpoints | Manual dual-datasource configurations in application ORMs prone to replica write exceptions and stale connection pool exhaustion |
| Connection Pooling & Process Multiplexing | Pre-forked pool tuning (num_init_children, max_pool) with connection cache reuse, protecting PostgreSQL from backend fork storms | PgBouncer excels at lightweight sub-millisecond transaction pooling but lacks read balancing; HAProxy maintains raw TCP streams with zero pooling | Unconstrained client connections spawning hundreds of heavy postgres OS backend processes, causing severe memory bloat and context switching |
| Watchdog HA & Quorum VIP Management | Multi-node Watchdog clustering with virtual IP (delegate_ip) failover, trusted server ping health checks, and automated split-brain avoidance | Requires external Keepalived or cloud load balancers with separate health check daemons and uncoordinated failover logic | Single-node proxy instances creating single points of failure, or uncoordinated Watchdog nodes fighting over duplicate virtual IPs |
| Automated Standby Online Recovery | Integrated recovery_1st_stage and 2nd_stage commands leveraging pg_basebackup to automatically reattach failed standbys with zero cluster downtime | No built-in standby recovery; requires separate orchestration tooling (pgBackRest, Patroni, or manual shell scripts) | Manual DBA intervention required to rebuild failed replicas, leading to extended periods of reduced read capacity during outages |
| In-Proxy Query Caching & Throttling | Selective shared-memory query caching for high-frequency read statements with automatic table-invalidation triggers and delay threshold gating | Neither PgBouncer nor HAProxy supports query caching; requires separate Redis/Memcached layers with app cache invalidation complexity | Every repeated query directly hits PostgreSQL shared buffers, causing cache churn, lock contention, and high CPU usage under spikes |
| Monitoring & Incident Response | Continuous pcp command audits, pool node health monitoring, Grafana dashboards, and senior DBREs on your incident bridge. SLA response times: P1 – 15 mins | P2 – 30 mins | P3 – 60 mins. | Generic infrastructure tickets with multi-hour turnaround and no deep Pgpool-II protocol-level diagnostic expertise | Engineers struggling to decipher Watchdog consensus logs and write_function_list errors at 2 AM during customer-facing outages |
Pgpool-II Tuning or PgBouncer + Patroni Assessment
Fixed-scope engagement to harden your existing Pgpool-II 4.4/4.5 cluster or evaluate a migration to PgBouncer + Patroni.
- Audit of `pgpool.conf`, child-process math, and `write_function_list` rules.
- 3-node Watchdog quorum hardening and `pcp_recovery_node` validation.
- Benchmark comparison against PgBouncer + HAProxy for your exact workload.
Ongoing PostgreSQL & Pgpool-II Support
Named senior PostgreSQL DBREs managing your Pgpool-II middleware and backend streaming replication nodes.
- 24/7 support. SLA response times: P1 – 15 mins | P2 – 30 mins | P3 – 60 mins.
- Proactive handling of detached nodes (`status 3`), online recovery, and minor upgrades.
- 24/7 monitoring of replication delay and child-process saturation.
Free Pgpool-II vs PgBouncer Architecture Review
Hitting `too many clients` errors or connection stalls in Pgpool-II? Get a senior PostgreSQL DBRE to inspect your `pgpool.conf`.
- Review of your `SHOW POOL_NODES`, `SHOW POOL_PROCESSES`, and `pgpool.conf`.
- Clear sizing formula for `num_init_children`, `max_pool`, and `max_connections`.
- 30-minute walkthrough with concrete remediation steps.
Procurement and security
Ready for legal and security review.
- Mutual NDA before any access
- Named individual accounts only
- Read-only access by default
- ISO 27001 & SOC 2 Type II: aligned, certification in progress
Mutual NDA before any access
We sign a mutual NDA before viewing schemas, logs, slow-query captures, or cloud topology.
Least-privilege, named credentials
Engineers connect through your bastion, VPN, or SSM using named accounts with read-only permissions by default.
Change control & approval gates
Production DDL, parameter changes, and failovers follow your change-management workflow with rollback steps prepared first.
Named leadership & direct escalation
Engagements are led by named senior database reliability engineers in India with direct Slack, Teams, and PagerDuty channels.
Pgpool-II vs PgBouncer & Technical FAQ
Frequently asked Pgpool-II questions.
Synced 1-to-1 with our structured FAQPage schema. Have a question about `num_init_children`, Watchdog VIPs, or migrating from Pgpool-II to PgBouncer? Ask our DBRE team.
Still have a question?
Ask it on a scoping call. No production access needed.
Book a 30-min scoping call (opens Google Calendar in a new tab)Pgpool-II vs PgBouncer: which one should we use for PostgreSQL?
How do `num_init_children` and `max_pool` interact with PostgreSQL `max_connections`?
How does Pgpool-II avoid stale read-after-write bugs on asynchronous standbys?
Can we stack PgBouncer in front of Pgpool-II?
Why does Pgpool-II Watchdog require 3 nodes instead of 2?
What are JusDB's SLA response times for Pgpool-II and PostgreSQL incidents?
Related Spokes, Tools & Reference Hubs
Continue exploring PostgreSQL middleware & HA.
Explore lightweight PgBouncer pooling, Patroni consensus failover, or our interactive PostgreSQL configuration calculator.
PgBouncer Reference Hub
Compare Pgpool-II child processes against PgBouncer libevent transaction pooling.
PgBouncer Consulting Services
Fixed-scope connection pooling and Pgpool-to-PgBouncer migration engagements.
Patroni Architecture Reference Hub
Modern etcd v3 consensus failover as an alternative to Pgpool-II failover scripts.
HAProxy Database Routing Hub
Port-based read/write splitting (:5000/:5001) with sub-millisecond TCP overhead.
PostgreSQL Config Optimizer
Calculate postgresql.conf shared_buffers, max_connections, and WAL settings.
PostgreSQL Consulting & DBRE Hub
End-to-end PostgreSQL HA, performance tuning, replication, and support available under your service agreement.
Ready to Optimize Pgpool-II?
Get a senior PostgreSQL DBRE to review your pgpool.conf and Watchdog topology.
Or request a free audit of one database instance, subject to availability: mutual NDA before read-only access, a prioritized report within one week after access is ready, and no obligation.







