public inbox for [email protected]  
help / color / mirror / Atom feed
Getting error "too many clients already" despite having a db connection limit set
2+ messages / 2 participants
[nested] [flat]

* Getting error "too many clients already" despite having a db connection limit set
@ 2025-06-16 16:29  adolfo flores <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: adolfo flores @ 2025-06-16 16:29 UTC (permalink / raw)
  To: [email protected]

Hello Team,

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.

The database that the app connects to, is configured with a connection
limit of 30% of the max_connections setting. Despite this limit being set
for that database, we're seeing the following errors in the PostgreSQL logs:

FATAL:  sorry, too many clients already
FATAL:  remaining connection slots are reserved for roles with the
SUPERUSER attribute


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?

Or any idea on what could be happening?


Regards.

Adolfo F.


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

* Re: Getting error "too many clients already" despite having a db connection limit set
@ 2025-06-16 16:39  Tom Lane <[email protected]>
  parent: adolfo flores <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2025-06-16 16:39 UTC (permalink / raw)
  To: adolfo flores <[email protected]>; +Cc: [email protected]

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






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


end of thread, other threads:[~2025-06-16 16:39 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-06-16 16:29 Getting error "too many clients already" despite having a db connection limit set adolfo flores <[email protected]>
2025-06-16 16:39 ` Tom Lane <[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