Enable Connection Manager's connection pooling for a PGD node group to maximize database throughput by recycling server connections across clients, preventing connection spikes from applications with many short-lived connections. Connection Manager's built-in transaction pooling requires no additional software to deploy or maintain.
For guidance on writing applications that work correctly with each pool mode, see Using connection pooling in your application.
Prerequisites
- Connection Manager running on each data node (PGD 6.4 and later). See Monitoring to verify it's running.
bdr_superuserrole or equivalent to runbdr.alter_node_group_option
Enabling connection pooling
Connection pooling is disabled by default, with server_pool_mode set to none. To enable it, set the mode to session or transaction for your node group.
Using SQL:
SELECT bdr.alter_node_group_option('mygroup', 'server_pool_mode', 'transaction');
Using the PGD CLI:
pgd group mygroup set-option server_pool_mode transaction
When enabling pooling, existing connections aren't affected and only new connections use the updated mode. When switching away from transaction mode, existing client connections with no open transaction are closed the next time they start a transaction.
Use transaction mode when connections are long-lived but transactions are short, with idle time between them, for example when client applications use their own connection pooling.
Use session mode for short-lived connections, or if your applications rely on session state that persists across transactions (such as SET, temporary tables, or advisory locks). For full details on each mode, see Connection pooling.
Warning
Transaction mode resets most session state at the end of each transaction. Before enabling it, check with your development team whether any applications rely on features that require session state to persist across transactions, such as WITH HOLD cursors, LISTEN, or SET changes. See Using connection pooling in your application for a full list of affected features.
Check the active pool mode.
SELECT node_group_name, server_pool_mode FROM bdr.node_group_summary;
Monitoring the pool
Monitoring Connection Manager describes the available metrics and HTTP endpoints for tracking active connections and pool utilization.
Migrating from pgBouncer
Connection Manager provides built-in connection pooling, removing the need for a separate pooler such as pgBouncer. Its pooling modes are similar to pgBouncer's session and transaction pooling modes. Follow these steps to migrate.
- Set
server_pool_modeto match your current pgBouncer pool mode (sessionortransaction). - Set
read_write_max_server_connectionsto a similar value as pgBouncer'spool_size, andread_write_max_client_connectionsto a similar value as pgBouncer'smax_client_conn. As a starting point, setread_only_max_server_connectionsandread_only_max_client_connectionsto the same values. Tune all four settings based on your actual workload. - Update application connection strings to point to Connection Manager's read-write port instead of pgBouncer.
- Verify application behavior:
- In
sessionmode, application behavior is unchanged from a direct Postgres connection. - In
transactionmode, pay particular attention to any use ofSETcommands, prepared statements, orWITH HOLDcursors, and adjust as needed. See Using connection pooling in your application.
- In
- Remove pgBouncer from your infrastructure once migration is verified.
Authentication configuration stays in pg_hba.conf on each PGD node. No separate user list or pooler configuration file is needed. Any user that can connect to Postgres through Connection Manager can use the pool, with no second place to grant or revoke access.
Connection Manager imposes additional restrictions compared to a direct Postgres connection in some scenarios. Test your application thoroughly before completing the migration.