Remediation Hub (9)
Add PgBouncer Transaction Pooling for Multi-Pod Chatwoot
PgBouncer multiplexes dozens of idle Puma and Sidekiq database threads onto 15-25 real PostgreSQL backends, slashing backend RAM overhead.
Pool Mode: transaction | PG Backends: 20 vs 80+ direct connections
Why Direct Puma + Sidekiq Connections Exhaust Postgres RAM
Each PostgreSQL backend process consumes 8-15 MB of private memory plus work_mem during sorts. Scaling Puma to 4 workers (20 threads) plus two Sidekiq pods (25 threads) demands 45+ open connections even when most threads sit idle waiting on HTTP webhooks.
Transaction Pooling Settings Compatible with Rails
Run PgBouncer with pool_mode = transaction, max_client_conn = 200, and default_pool_size = 20. In Chatwoot Rails database configuration, disable prepared statements (prepared_statements: false) when routing through transaction-mode PgBouncer.
Measured Thresholds & Configuration
| PgBouncer Setting | Recommended Value | Operational Benefit |
|---|---|---|
| pool_mode | transaction | Reuses PG backends across idle Rails threads |
| default_pool_size | 20 (per DB) | Caps active PG processes inside RAM budget |
| prepared_statements | false in Rails DB config | Prevents PG statement mismatch errors |