Free audit

View Audit Scope
JusDBPgpool-II 4.4 / 4.5 · SQL Load Balancing, Pooling & Watchdog HA

Pgpool-II architecture, pgpool.conf reference & PgBouncer comparison.

Pgpool-II is the all-in-one PostgreSQL middleware that combines SQL-aware read/write load balancing, connection pooling, automated failover, online node recovery (`pcp_recovery_node`), and Watchdog Virtual IP quorum on a single port (:9999). When engineering teams evaluate Pgpool vs PgBouncer, the choice comes down to whether your application needs transparent single-port SQL read/write splitting or ultra-lightweight transaction multiplexing. This hub documents `pgpool.conf` sizing invariants and PCP runbooks, backed by a 15-minute P1 response SLA.

Pgpool-II

SQL Router & Watchdog (:9999 / :9898)

SQL Load Balancer

recommended

Parses PostgreSQL wire-protocol queries to send writes, `SELECT ... FOR UPDATE`, and volatile functions to the primary while balancing safe SELECTs across standbys.

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

  • Innoviti
  • Blitz
  • Freecharge
  • Nango
  • Recochain
  • Screen Facts
  • Nexora
  • WeCredit

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.

P1 incidents, 24/7

15 mins

Response SLA

P1 response SLA: 15 mins, 24/7.

P2 incidents, 24/7

30 mins

Response SLA

P2 response SLA: 30 mins, 24/7.

P3 incidents, 24/7

60 mins

Response SLA

P3 response SLA: 60 mins, 24/7.

SLA response times by severity (24/7)

P1 · Critical15 mins

Production database down, primary unreachable, data corruption risk, or active failover event.

P2 · High30 mins

Severe latency spike, replication lag climbing rapidly, connection exhaustion, or degraded HA node.

P3 · Medium60 mins

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.

load_balance_mode · write_function_list · SHOW POOL_NODES

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.
num_init_children · max_pool · serialize_accept

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`.
use_watchdog · delegate_ip · pcp_watchdog_info

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.
pcp_recovery_node · follow_primary_command · auto_failback

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 vs PgBouncer · Patroni · HAProxy

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.
memory_cache_enabled · SHOW POOL_CACHE · pgpool2_exporter

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.

Active
  • 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.

Production Configuration Specimen · Pgpool-II 4.5

Right-Sized pgpool.conf & PCP Online Standby Recovery Runbook

Before: 1,000 backend slots · 53300 errorsAfter: 240 bounded slots · dynamic spare pool

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 LayerCustomer TeamJusDB DBRE Team
Application SQL & Function VolatilityConnect apps to Pgpool-II VIP (:9999) and declare mutating functionsAudit SQL traffic, populate `write_function_list`, and configure `disable_load_balance_on_write`
`pgpool.conf` & Child Pool MathApprove maintenance windows and infrastructure PRsCalculate `num_init_children`, `max_pool`, and `process_management_mode` against `max_connections`
Watchdog VIP & Failover ScriptsProvide 3 proxy VMs and `/sbin/ip` `CAP_NET_ADMIN` or sudoers permissionsAuthor `failover.sh`, `follow_primary.sh`, and `escalation.sh` with quorum safeguards
PCP Online Recovery (`pcp_recovery_node`)Allow SSH/replication traffic between PostgreSQL data nodesConfigure `recovery_1st_stage` scripts and test single-command standby rebuilds
24/7 Telemetry & Incident ResponseReceive Slack/PagerDuty notifications on SLA eventsMonitor `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 VectorJusDB Pgpool-II DBREPgBouncer / HAProxyDirect / In-House
Query Inspection & Read/Write SplittingIntelligent SQL parsing routes SELECT to read replicas and INSERT/UPDATE/DELETE to primary without application code changes or dual connection poolsPgBouncer does no SQL parsing; HAProxy requires dual listening ports and application-level routing logic across distinct database endpointsManual dual-datasource configurations in application ORMs prone to replica write exceptions and stale connection pool exhaustion
Connection Pooling & Process MultiplexingPre-forked pool tuning (num_init_children, max_pool) with connection cache reuse, protecting PostgreSQL from backend fork stormsPgBouncer excels at lightweight sub-millisecond transaction pooling but lacks read balancing; HAProxy maintains raw TCP streams with zero poolingUnconstrained client connections spawning hundreds of heavy postgres OS backend processes, causing severe memory bloat and context switching
Watchdog HA & Quorum VIP ManagementMulti-node Watchdog clustering with virtual IP (delegate_ip) failover, trusted server ping health checks, and automated split-brain avoidanceRequires external Keepalived or cloud load balancers with separate health check daemons and uncoordinated failover logicSingle-node proxy instances creating single points of failure, or uncoordinated Watchdog nodes fighting over duplicate virtual IPs
Automated Standby Online RecoveryIntegrated recovery_1st_stage and 2nd_stage commands leveraging pg_basebackup to automatically reattach failed standbys with zero cluster downtimeNo 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 & ThrottlingSelective shared-memory query caching for high-frequency read statements with automatic table-invalidation triggers and delay threshold gatingNeither PgBouncer nor HAProxy supports query caching; requires separate Redis/Memcached layers with app cache invalidation complexityEvery repeated query directly hits PostgreSQL shared buffers, causing cache churn, lock contention, and high CPU usage under spikes
Monitoring & Incident ResponseContinuous 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 expertiseEngineers struggling to decipher Watchdog consensus logs and write_function_list errors at 2 AM during customer-facing outages
Architecture & Optimization

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.
Managed DBRE Retainer

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 Engineering Entry Point

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, least-privilege credentials in your vault, and security controls aligned with ISO 27001 and SOC 2 Type II. JusDB's security practices are aligned with ISO 27001 and SOC 2 Type II, and JusDB is pursuing both certifications (see Terms, section 12).
  • 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?

Choose **PgBouncer** (paired with Patroni and HAProxy) when your primary challenge is multiplexing thousands of short-lived client connections onto a small number of PostgreSQL processes with minimal memory (~2 KB/conn) and latency overhead. Choose **Pgpool-II** when your application can only connect to a single database host/port and requires the proxy itself to parse SQL statements and split `SELECT` queries across read replicas automatically, or when you want built-in Watchdog VIP management and `pcp_recovery_node` in one package.

How do `num_init_children` and `max_pool` interact with PostgreSQL `max_connections`?

Pgpool-II pre-forks `num_init_children` worker processes. Each worker process accepts at most 1 active client connection at a time, and caches up to `max_pool` backend connections to each PostgreSQL node (indexed by `(user, database)` pair). Therefore, a single Pgpool-II instance can open up to `num_init_children * max_pool` connections to each PostgreSQL server. You must enforce `(num_init_children * max_pool * number_of_pgpool_nodes) <= (max_connections - superuser_reserved_connections)` or PostgreSQL will reject connections under load.

How does Pgpool-II avoid stale read-after-write bugs on asynchronous standbys?

Pgpool-II provides two complementary settings in `pgpool.conf`: (1) `disable_load_balance_on_write = 'trans_transaction'` (which routes all subsequent `SELECT` statements in the current transaction AND the rest of the session/subsequent transactions to the primary after a write occurs) and (2) `delay_threshold_by_time` (for example, `2000ms`), which checks WAL replay delay every `sr_check_period` and stops sending reads to any standby exceeding the threshold.

Can we stack PgBouncer in front of Pgpool-II?

Yes. Because Pgpool-II uses a heavy process-per-client-connection model (`num_init_children`), placing lightweight PgBouncer (`pool_mode = transaction`) between a large Kubernetes microservice fleet (5,000+ connections) and Pgpool-II (150 `num_init_children`) prevents client connection spikes from exhausting Pgpool-II child processes while preserving Pgpool-II's SQL read/write splitting.

Why does Pgpool-II Watchdog require 3 nodes instead of 2?

Watchdog uses a quorum-voting protocol (`failover_when_quorum_exists = on` and `failover_require_consensus = on`) to elect the active coordinator that holds the Virtual IP (`delegate_ip`) and executes `failover_command`. With only 2 Pgpool-II nodes, losing 1 node or experiencing a network split leaves neither side with a strict majority (`>50%`). Running 3 Pgpool-II Watchdog nodes across separate failure domains ensures a 2-of-3 quorum survives any single node failure.

What are JusDB's SLA response times for Pgpool-II and PostgreSQL incidents?

24/7 support. SLA response times: P1 – 15 mins | P2 – 30 mins | P3 – 60 mins. P1 covers a critical production outage, Watchdog split-brain, or failed primary promotion. Response means an on-call engineer is working the incident, not an automated reply.