public inbox for [email protected]  
help / color / mirror / Atom feed
Re: Pgbouncer and Node JS application Query read timeout error
2+ messages / 2 participants
[nested] [flat]

* Re: Pgbouncer and Node JS application Query read timeout error
@ 2026-04-10 07:07 KK CHN <[email protected]>
  2026-04-10 07:29 ` Re: Pgbouncer and Node JS application Query read timeout error Laurenz Albe <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: KK CHN @ 2026-04-10 07:07 UTC (permalink / raw)
  To: Laurenz Albe <[email protected]>; +Cc: pgsql-general

On Wed, Apr 8, 2026 at 11:58 AM Laurenz Albe <[email protected]>
wrote:

> On Wed, 2026-04-08 at 10:51 +0530, KK CHN wrote:
> > List, I am using pgbouncer(PgBouncer 1.23.1 RHEL 9.4) along with
> Postgres16(RHEL 9.4)
> > for connection pooling.
> >
> > Running a nodejs application which is throwing some errors  related to
> query timeout
> > which the development team suspect after pgbouncer deployment
> this behaviour appears,
> > but not sure
> >
> > The error which is thrown from  the nodejs logs as follows..
> >
> > [image showing an error "Query read timeout"]
> >
> > Is this due to   pgbouncer config issues or   nodejs  pool config issues
> ?
> >
> > for  reference here the pgbouncer  config params and  node js  params at
> present.
> >
> > pgbouncer.ini
> >
> > [...]
> > [pgbouncer]
> > pool_mode = transaction
> > default_pool_size = 50
> > min_pool_size = 30
> > reserve_pool_size = 10
> > reserve_pool_timeout = 5
> > max_db_connections = 130
> > max_user_connections = 180
> > server_lifetime = 3600
> > server_idle_timeout = 600
> > [...]
>
>
> The only way I can imagine that pgBouncer is leading to timeouts on the
> client side
> is if client sessions are waiting, because all connections are in use.
>
> You can run SHOW POOLS in the pgBouncer console to see if there are any
> "cl_waiting".
> If that is the case, you should configure the Node.js pools smaller, so
> that no
> connection has to wait.
>

Configuring Node.js  pools smaller ?  I couldn't get the  logic here  why
advised to reduce the pool size ?

Increasing pool size  more than 10 adversely affects the connection
establishment from Node.js  application ?          Since DB  is having
 Pgbouncer infront and   default_pool_size = 50 there ,  don't we have the
freedom to increase node.js application pool size and it will help the
query timeout ?   or any hidden facts involved could you elaborate ..


Thank you,
Krishane



>
> Yours,
> Laurenz Albe
>


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Pgbouncer and Node JS application Query read timeout error
  2026-04-10 07:07 Re: Pgbouncer and Node JS application Query read timeout error KK CHN <[email protected]>
@ 2026-04-10 07:29 ` Laurenz Albe <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Laurenz Albe @ 2026-04-10 07:29 UTC (permalink / raw)
  To: KK CHN <[email protected]>; +Cc: pgsql-general

On Fri, 2026-04-10 at 12:37 +0530, KK CHN wrote:
> > The only way I can imagine that pgBouncer is leading to timeouts on the client side
> > is if client sessions are waiting, because all connections are in use.
> > 
> > You can run SHOW POOLS in the pgBouncer console to see if there are any "cl_waiting".
> > If that is the case, you should configure the Node.js pools smaller, so that no
> > connection has to wait.
> 
> Configuring Node.js  pools smaller ?  I couldn't get the  logic here  why advised to reduce the pool size ? 
>  
> Increasing pool size  more than 10 adversely affects the connection  establishment from
> Node.js  application ?          Since DB  is having   Pgbouncer infront and
> default_pool_size = 50 there ,  don't we have the freedom to increase node.js application
> pool size and it will help the query timeout ?   or any hidden facts involved could you elaborate ..

There are no hidden facts.

You asked if pgBouncer could lead to query timeouts.  I answered that the only way a query
could take significantly longer with pgBouncer is if the client has to wait for a pooled
connections, that is, if the connection pool in pgBouncer is smaller than the number of
clients that want to run a transaction concurrently.

BEFORE you take any action, you should figure out if that is the case by looking
at SHOW POOLS.  Since you didn't report any findings, I assume that you launched your
volley of questions before doing the required investigation.  Bad idea.

IF (and only if) there are indeed client sessions waiting for a pooled connection,
you could react in two different ways:

- increase the pgBouncer pool size
- reduce the application server pool size

Obvious, isn't it?

Increasing the pgBouncer pool size is a good idea only if your database machine can
stomach the additional load.  If not, reducing the application server pool size is
the correct measure.  If the application load is too much for the database, somebody
has to suffer.  If you choose to overload the database, everybody will be unhappy.
If you throttle the load in the connection pool, only some client will be unhappy
(those that have to wait and get a timeout).

You will have to diagnose what the exact problem is.

Yours,
Laurenz Albe






^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2026-04-10 07:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-04-10 07:07 Re: Pgbouncer and Node JS application Query read timeout error KK CHN <[email protected]>
2026-04-10 07:29 ` Laurenz Albe <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox