public inbox for [email protected]
help / color / mirror / Atom feedFrom: Laurenz Albe <[email protected]>
To: Raj <[email protected]>
To: [email protected]
Cc: Pgsql-admin <[email protected]>
Subject: Re: Pgbouncer
Date: Fri, 12 Sep 2025 07:26:08 +0200
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAJk5Atb_fEjofuXBXqEKF4+yh69ePjCFNLX3T2+C4QMbLf_1pA@mail.gmail.com>
References: <CAJk5Atanc-d4xg_3UxbTybvNmPfb593WAhLFqjAWEUhm5cYQDQ@mail.gmail.com>
<[email protected]>
<CAJk5Atb_fEjofuXBXqEKF4+yh69ePjCFNLX3T2+C4QMbLf_1pA@mail.gmail.com>
On Thu, 2025-09-11 at 22:11 +0530, Raj wrote:
> I am asking should we use pgbouncer? If so, what's the compelling situation
> despite having postgres inbuilt timeout parameters.
Timeouts and connection pooling have little to do with each other.
You want timeouts so that statements and transactions cannot take too long,
hog resources and damage your database.
Connection pooling has a different purpose. It is necessary, because you
cannot afford to have short-lived database sessions. So you want persistent
database session, but you don't want too many of them because
- the more you have, the bigger the risk of overloading the database
- if you have many connections, you cannot set "work_mem" too high, which
will be bad for the performance of your SQL statements
- switching between processes means overhead for the kernel
- the more sessions you have, the longer the snapshot PostgreSQL takes at
the start of each statement will take
If you have a single application server, you don't need pgBouncer. Simply
use the connection pooler built into your application server. Only when you
start many instances of your application server (which would mean many pools)
you need an external pooler like pgBouncer.
If you want more reading material:
https://www.cybertec-postgresql.com/estimating-connection-pool-size-with-postgresql-database-statist...
https://www.cybertec-postgresql.com/tuning-max_connections-in-postgresql/
https://www.postgresql.eu/events/pgconfeu2022/sessions/session/3811/slides/327/1000_application_user...
Yours,
Laurenz Albe
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected]
Subject: Re: Pgbouncer
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox