Skip to main content
iVentureTeam
Odoo Implementation

Odoo PgBouncer Guide: Session vs Transaction Pooling for Odoo 19/20

Set up PgBouncer for Odoo 19 and 20: session vs transaction pooling, the bus and cron LISTEN catch, db_maxconn math, sample config and Odoo.sh limits.

Siddharth JambukiyaSiddharth JambukiyaOdoo Techno-Functional Consultant
November 23, 202612 min read0 views
Odoo PgBouncer Guide: Session vs Transaction Pooling for Odoo 19/20 cover

Most PgBouncer advice for Odoo stops at "use session mode to be safe". That works, but it throws away most of the benefit. Our Odoo ERP support team uses a split setup instead, and this guide shows the config, the math and the failure modes.

Related service: Odoo implementation services — fixed-scope implementations with a named senior team.

This guide is for sysadmins and IT leads who self-host Odoo 19 or 20. It skips worker and memory sizing, which our Odoo performance tuning checklist covers in depth.

What is PgBouncer and why would Odoo need it?

PgBouncer is a small connection pooler that sits between Odoo and PostgreSQL, so many client connections share a few real database connections. Odoo needs it only when connection count, not CPU or slow code, is the limit.

Every PostgreSQL connection is a separate server process. Each Odoo HTTP worker, cron worker and websocket worker keeps its own pool. Add a second node, a reporting tool and backups, and the total climbs fast.

When the total passes PostgreSQL's max_connections setting, new connections fail with PostgreSQL's "sorry, too many clients already" error. Users see random errors, cron jobs fail and the websocket drops.

On the Odoo forum, an admin asked how to set max_connections to 100,000. The accepted reply: use connection pooling instead of a huge max_connections value and keep the PostgreSQL limit moderate. That is exactly the job PgBouncer does.

How many PostgreSQL connections does Odoo open?

Each Odoo process has its own connection pool capped by db_maxconn, which defaults to 64, so the worst case is processes times db_maxconn. Real use is far lower, but the worst case is what breaks at peak.

Odoo's command-line reference and config code define the options that matter. The defaults below come from the Odoo 19 and 20 source.

Odoo optionDefaultWhat it controls
workers0 (threaded mode)HTTP worker processes in multi-processing mode
max_cron_threads2Cron workers, on top of the HTTP workers
gevent_port8072Port of the websocket (LiveChat) worker
db_maxconn64Max physical connections per Odoo process
db_maxconn_geventnot setSeparate cap for the websocket worker
db_system (Odoo 20)postgresDatabase used for bus and cron signals

Odoo's deployment guide sample uses 8 workers and 1 cron worker. Add the websocket worker and that is 10 processes. At db_maxconn 64, the illustrative worst case is 640 connections per node.

The same guide shows max_connections = 80 for PostgreSQL. Most requests use one or two connections, so you rarely hit 640, but two nodes and a stuck cron at peak can pass 80.

Session pooling vs transaction pooling for Odoo

PgBouncer pooling modes: Which mode fits each Odoo database?

Session pooling gives each client a server connection for as long as it stays connected, while transaction pooling lends one only for the length of a transaction. For Odoo the second saves far more, but it breaks LISTEN.

The official PgBouncer feature list says transaction pooling "breaks a few session-based features of PostgreSQL" and works only when the application avoids them. Its compatibility table, as checked on 2026-11-23, is summed up here.

PostgreSQL featureSession poolingTransaction poolingOdoo impact
LISTENYesNeverBus and cron triggers break
NOTIFYYesYesSending bus messages still works
SET / RESETYesNeverCheck custom modules
Session-level advisory locksYesNeverCheck custom modules
WITH HOLD cursorsYesNeverRare in Odoo code
Protocol-level prepared plansYesYes, with max_prepared_statementsNot a usual Odoo issue

Statement pooling forbids multi-statement transactions, so it does not suit Odoo. Odoo's HTTP requests are short transactions, which suit transaction pooling well. The problem is the two listeners, covered next.

Why does the Odoo websocket break behind PgBouncer?

The Odoo websocket worker and the cron workers keep a connection open and run LISTEN on it, and transaction pooling never supports LISTEN. So chat, notifications and instant cron triggers stop while normal pages still work.

In the Odoo 19 source, the bus loop connects to the "postgres" database and runs `listen imbus`. The cron workers run `LISTEN cron_trigger` on the same database. In Odoo 20 both use the new db_system option, which still defaults to "postgres".

An Odoo forum report matches this. With PgBouncer in transaction mode, an admin found cron and chat became inoperative, while session mode worked but gave "no real benefit".

The symptoms of a broken listener are easy to miss:

  • Discuss messages and notifications appear only after a page refresh.
  • The browser console shows the websocket reconnecting in a loop.
  • Scheduled actions triggered by code run late, at the next polling cycle, instead of at once.
  • Server logs show errors on the bus loop or the cron listener.

NOTIFY still works in transaction mode. Only the listening side fails, so the bug feels random.

The split setup: transaction pooling with a session pool for bus and cron

Point Odoo at PgBouncer, give the system database a session-mode entry, and pool every business database in transaction mode. PgBouncer allows pool_mode per database, so one PgBouncer can do both.

The PgBouncer configuration reference confirms that a [databases] entry can set pool_mode, pool_size and max_db_connections, and that "*" acts as a fallback for any other database name. That is all this setup needs.

Here is an illustrative pgbouncer.ini for one PostgreSQL server on the same host. Adjust hosts, sizes and auth to your setup.

```ini [databases] postgres = host=127.0.0.1 port=5432 pool_mode=session pool_size=10 * = host=127.0.0.1 port=5432 pool_mode=transaction

[pgbouncer] listen_addr = 127.0.0.1 listen_port = 6432 auth_type = scram-sha-256 auth_file = /etc/pgbouncer/userlist.txt max_client_conn = 1000 default_pool_size = 20 reserve_pool_size = 5 max_db_connections = 60 ```

Then point Odoo at PgBouncer instead of PostgreSQL. This is the pgbouncer odoo configuration on the Odoo side.

```ini [options] db_host = 127.0.0.1 db_port = 6432 workers = 8 max_cron_threads = 1 db_maxconn = 32 proxy_mode = True ```

On Odoo 20, if you set db_system to another name, rename the session entry to match. If your session entry and the real name differ, the listeners silently fall into transaction mode.

How to roll out PgBouncer for Odoo safely

Roll PgBouncer out in staging first, test the listeners on purpose, then switch production in a quiet window. The steps below are the order we follow.

  1. Measure first: count connections by application_name in pg_stat_activity at peak, so you know the real problem is connections.
  2. Install PgBouncer on the Odoo host or the database host, and copy the Odoo database user into the auth file with a SCRAM secret.
  3. Start in session mode for every database, point staging Odoo at port 6432 and confirm nothing changes.
  4. Switch the business database to transaction mode, keep the system database in session mode, and restart Odoo.
  5. Test the listeners: send a Discuss message between two browsers, trigger a scheduled action from code and watch it run at once.
  6. Test the heavy paths: a large report, an import, a POS session and any custom module that touches raw SQL.
  7. Load test with your peak user count and watch PgBouncer's SHOW POOLS for waiting clients.
  8. Go to production in a low-traffic window, with the old db_port ready to restore in one config change.

Run this on a copy first. Our Odoo staging environment checklist explains how to neutralize that copy so it does not send mail or run real payments.

PgBouncer failure modes we check before go-live

Most PgBouncer trouble with Odoo comes from four places: listeners, custom SQL, pool sizes and tools that should bypass the pooler. Each one has a clear check.

Failure modeSymptomCheck or fix
Listener in transaction modeChat and cron triggers delayedSession entry for postgres or db_system
Custom module uses SET or session locksWrong settings or locks on another requestSearch code; use SET LOCAL or transaction locks
Pool too smallRequests wait, then time outRaise pool_size; watch waiting clients
max_client_conn too lowNew Odoo connections refusedCover workers times db_maxconn
Backups through PgBouncerLong dumps hold pool slotsRun pg_dump straight to PostgreSQL
Wrong auth typeLogin fails after PostgreSQL upgradeMatch SCRAM on both sides

Long cron jobs hold a pooled server connection for their whole run, so set pool_size above your cron count. Our guide to Odoo scheduled actions and cron batching shows how to split long jobs.

Odoo.sh vs self-hosted: where PgBouncer applies

PgBouncer is a self-hosted tool: on Odoo.sh and Odoo Online, Odoo runs PostgreSQL for you and you cannot add a pooler. The right lever depends on where you host.

HostingCan you add PgBouncer?What to do instead
Odoo OnlineNo server accessReport slowness to Odoo Support
Odoo.shNo pooler setting in the docsBuy extra workers; fix slow code
Self-hosted, one serverYes, often optionalLower db_maxconn first, then add PgBouncer
Self-hosted, several nodesYes, usually worth itSplit setup with a session pool for listeners
Managed cloud PostgreSQLOften a built-in poolerApply the same session and transaction split

The Odoo.sh docs say extra database workers are added through your account manager, and warn this "does not automatically fix performance issues".

If you are still choosing a platform, compare the trade-offs in our guide to Odoo Online vs Odoo.sh vs on-premise. Self-hosting gives you PgBouncer, and also the job of running it.

When PgBouncer will not fix a slow Odoo

PgBouncer fixes connection exhaustion and connection churn; it does not make slow queries, heavy computed fields or too few workers faster. If CPU or a slow report is the cause, pooling only moves the queue.

Signs that you need PgBouncer:

  • PostgreSQL logs "too many clients already" at peak.
  • You run two or more Odoo nodes, or many databases, against one PostgreSQL server.
  • pg_stat_activity shows hundreds of idle Odoo connections.

Signs that you need something else:

  • One report or one screen is slow even with two users.
  • CPU on the Odoo host sits near 100%.
  • Workers hit limit_time_real and get killed.

One Odoo forum admin said their team tried PgBouncer and Pgpool-II and neither worked for them. A missing listener split is a common cause.

For capacity at 500 users and beyond, see whether Odoo can scale to 500 or 1,000 users.

Which industries hit Odoo connection limits first?

Businesses with many users at the same moment, long reports or many databases on one server hit connection limits first. The pattern depends on the shape of the load, not only on user count.

IndustryPain or cost driverOdoo approachHow iVentureTeam helps
Retail and POS chainsMany tills syncing at store open and closeShort transactions suit poolingSize pools for opening-hour peaks
eCommerceTraffic spikes from campaignsMore workers plus PgBouncerLoad test before big sales
ManufacturingLong MRP and costing cron jobsSession-safe cron, larger poolSplit and batch heavy jobs
Distribution and 3PLMany barcode scanners and API callsTransaction pooling for API loadCheck integrations on staging
Hosting providers and groupsMany databases on one PostgreSQLOne PgBouncer with per-database poolsSet pool caps per database
Services and SaaS teamsHeavy Discuss and chat useSession pool for the busTest websocket under load

How iVentureTeam helps with Odoo PgBouncer and connection pooling

Odoo feeling slow? Check it first

We find out whether connections are really your bottleneck, then set up and test pooling so chat, cron and reports keep working. We have delivered 150+ ERP projects across 35+ countries with 40+ Odoo specialists, led by a consultant with 13+ years in Odoo.

  • Diagnosis: pg_stat_activity, worker and cron review, and a short report on what limits you.
  • Setup: the split PgBouncer configuration, auth, and Odoo config changes, done by our DevOps and cloud services team.
  • Testing: websocket, cron triggers, POS, imports and custom SQL checked in staging before production.
  • Hardening: network rules and credentials for PgBouncer, in line with our Odoo security guide.
  • Ongoing support: monitoring of pool waits and connection counts as you grow.

Not sure where you stand? Run the free Odoo health check to see your version, modules and findings first.

Odoo PostgreSQL workload case study: Indep Consulting

A Belgian cleaning-chemicals firm runs sales, stock, accounting, eCommerce and contracts on one Odoo database, with management reports written in SQL. That mix of webshop traffic and direct SQL reporting is the kind of load where connection planning matters.

iVentureTeam rolled out Sales, CRM, Inventory, Accounting and eCommerce, plus EDI with trading partners and intercompany transfer rules. The project ran for 12 weeks.

We built 8 custom SQL reports, from product margin to stock rotation, directly on SQL queries for speed and precision. The company reports a 2x faster management reporting cycle.

Read the full Indep Consulting Odoo ERP and SQL reporting case study.

The bottom line on Odoo PgBouncer

Use PgBouncer on self-hosted Odoo when connections run out, pool business databases in transaction mode, and keep the bus and cron listeners on a session-mode entry. On Odoo.sh or Odoo Online, fix code and buy workers instead.

Measure first. If idle connections and "too many clients" errors are the problem, the split setup gives most of the savings without breaking chat or cron.

Ready to fix Odoo connection limits?

Book a PgBouncer review

Get a pooling plan tested on your own staging copy. Ask our team for an Odoo PgBouncer review, call +91-90235-15208, or email business@iventureteam.com.

Frequently Asked Questions

Does Odoo work with PgBouncer?

+

Yes, on self-hosted Odoo. Transaction pooling works for normal requests, but the bus and cron listeners need a session-mode entry for the postgres database, or the db_system database in Odoo 20.

Should I use session or transaction pooling for Odoo?

+

Use both. Pool the business database in transaction mode to save connections, and keep the system database that Odoo's bus and cron listen on in session mode, because transaction pooling never supports LISTEN.

Why does Odoo chat stop working behind PgBouncer?

+

The websocket worker runs LISTEN imbus on a long-lived connection. In transaction mode PgBouncer cannot support LISTEN, so messages appear only after a refresh. A session-mode entry for that database fixes it.

What is db_maxconn in Odoo?

+

It is the maximum number of physical PostgreSQL connections each Odoo process may open. The default is 64. Multiply it by your workers, cron workers and websocket worker to get the worst case.

How do I fix the too many clients already error in Odoo?

+

First lower db_maxconn and check for idle or stuck connections in pg_stat_activity. If you run several nodes or databases, add PgBouncer in front of PostgreSQL instead of raising max_connections very high.

Can I use PgBouncer on Odoo.sh?

+

No. Odoo manages PostgreSQL on Odoo.sh and its docs offer no pooler setting. To handle more concurrent load you buy extra workers through your account manager, and fix slow code first.

Does PgBouncer make Odoo faster?

+

Only when connections are the limit. It cuts connection churn and idle server processes. It does not speed up slow queries, heavy computed fields or an overloaded CPU.

Do Odoo 19 and Odoo 20 need different PgBouncer settings?

+

Mostly no. The one change is that Odoo 20 adds the db_system option for bus and cron signals. It defaults to postgres, so rename your session-mode entry only if you change it.

Free Odoo support review

Need dependable Odoo support?

Tell us what's going wrong or what you need covered. We suggest a support plan that fits how you use Odoo.

Free, with no obligation. A senior consultant replies within 12 business hours.

We use cookies to improve your experience

Essential cookies make the site work, and we use analytics to improve it. Choose “Only necessary” to turn analytics off. See our cookie policy.