Skip to Content

What is PgBouncer and why does Odoo need it

November 5, 2025 by
What is PgBouncer and why does Odoo need it
John Wolf
| No comments yet

🧠 The turning point

If you've made it this far, you already know that:

  • Odoo opens many connections

  • PostgreSQL does not scale well with them

  • The problemis not solved within Odoo

This is where PgBouncer comes in.


🔌 What is PgBouncer (without marketing)

PgBouncer is aconnection pooler for PostgreSQL.

In simple terms:

  • Odoo opensmany logical connections

  • PgBouncer maintainsfew real connections

  • PostgreSQL only sees what it can handle

PgBouncer sitsbetween Odoo and PostgreSQL:

Odoo → PgBouncer → PostgreSQL


🧩 What problem does it exactly solve

Without PgBouncer:

  • Each Odoo worker opens its connection

  • PostgreSQL creates a process for each connection

  • Memory spikes

  • Latency increases

With PgBouncer:

  • Connections arereused

  • PostgreSQL has fewer processes

  • Less RAM per connection

  • Fewer unnecessary locks

  • More stable latency

🔄 Pooling: the key idea

PgBouncer works with a simple but powerful concept:

One real connection can serve many clients, but not at the same time.

When a transaction ends:

  • the connection returns to the pool

  • another request reuses it

  • PostgreSQL never sees the actual peak of users

⚙️ Why Odoo can't do this alone

Odoo:

  • does not have real internal pooling

  • assumes direct connection

  • keeps transactions open longer than ideal

Additionally:

  • the ORM is not designed to share connections

  • changing this in Odoo would break compatibility

👉 PgBouncerdoes not replace Odoo, it complements it.

🧨 The common mistake: “my server holds up without PgBouncer”

Yes, it holds up… until it doesn't.

This usually happens:

  • few users → all good

  • usage grows → intermittent latency

  • you increase max_connections

  • more RAM consumed

  • one day it collapses

PgBounceris not optionalin serious production.

🧪 Real example (simplified)

Scenario without PgBouncer:

  • 12 workers

  • 20 concurrent users

  • 40–60 real connections

  • PostgreSQL with wasted RAM

With PgBouncer:

  • 12 workers

  • 20 concurrent users

  • 10–15 real connections

  • stable PostgreSQL

👉 Same Odoo,totally different behavior.

🧠 PgBouncer does not speed up queries (and that's a good thing)

Important to clarify:

  • PgBouncerdoes not make queries faster

  • does not cache results

  • does not optimize SQL

What it does is:

  • prevent collapse

  • reduce overhead

  • stabilize the system

Speed improvesbecause the system stops fighting with itself.

⚠️ Poorly configured PgBouncer can make everything worse

PgBouncer is not magic:

  • wrong pool_mode breaks Odoo

  • poorly calculated pool sizes cause starvation

  • badly done auth breaks connections

  • cron jobs can block pools

👉 That's why this course exists.

Next chapter ->

What is PgBouncer and why does Odoo need it
John Wolf November 5, 2025
Share this post
Tags
Archive
Sign in to leave a comment