public inbox for [email protected]  
help / color / mirror / Atom feed
From: Marco Torres <[email protected]>
To: Tom Lane <[email protected]>
Cc: adolfo flores <[email protected]>
Cc: [email protected]
Subject: Re: Getting error "too many clients already" despite having a db connection limit set
Date: Mon, 16 Jun 2025 10:41:44 -0600
Message-ID: <CAG2LZV7pSbd7Snx_foov-tkXw050sD54EiPv0x0C4J9VFxWG9g@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <CADM4kyuO39mr8E_xDw4GGi2v9gCK0dq52fKj40FcsXJeKxgRrA@mail.gmail.com>
	<[email protected]>

You might want to explore pgpool and pgbouncer. Depending in your use case
you might want to glue them togeter.

On Mon, Jun 16, 2025, 10:39 AM Tom Lane <[email protected]> wrote:

> adolfo flores <[email protected]> writes:
> > I hope you can help me with an issue we're experiencing. We have an app
> > running on Kubernetes that opens a huge number of connections within a
> > couple of seconds.
>
> You need to fix that app to be less unfriendly, or maybe put it behind
> a connection pooler.
>
> > Is it expected behavior to reach the max_connections limit when that app
> > opens many connections in a short period of time, even if a connection
> > limit is set for that database and everything else uses no more than 10%
> of
> > the max_connections?
>
> It takes a finite amount of time for a new backend process to figure
> out which database it's supposed to connect to and then detect whether
> the per-DB connection limit is exceeded.  In the meantime, that
> session does count against the global limit, so yeah this isn't
> surprising if the connection arrival rate is high enough.
>
>                         regards, tom lane
>
>
>


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: Getting error "too many clients already" despite having a db connection limit set
  In-Reply-To: <CAG2LZV7pSbd7Snx_foov-tkXw050sD54EiPv0x0C4J9VFxWG9g@mail.gmail.com>

* 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