Re: Getting error "too many clients already" despite having a db connection limit set - Mailing list pgsql-general

From Tom Lane
Subject Re: Getting error "too many clients already" despite having a db connection limit set
Date
Msg-id 536522.1750091949@sss.pgh.pa.us
Whole thread Raw
In response to Getting error "too many clients already" despite having a db connection limit set  (adolfo flores <adolfoflores2211@gmail.com>)
Responses Re: Getting error "too many clients already" despite having a db connection limit set
List pgsql-general
adolfo flores <adolfoflores2211@gmail.com> 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



pgsql-general by date:

Previous
From: adolfo flores
Date:
Subject: Getting error "too many clients already" despite having a db connection limit set
Next
From: Marco Torres
Date:
Subject: Re: Getting error "too many clients already" despite having a db connection limit set