Re: Connections Increasing Slowly

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Bee(dot)Lists" <bee(dot)lists(at)gmail(dot)com>
Cc: Submit Postgresql Novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Connections Increasing Slowly
Date: 2020-06-22 20:11:48
Message-ID: 2088230.1592856708@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

"Bee.Lists" <bee(dot)lists(at)gmail(dot)com> writes:
> Hi folks. My PostgreSQL server has a growing number of connections.
> Currently it’s at 115. max_connections set to 300. It’s being accessed from public (web application), server cron once a day, and two clients on the LAN, a handful of times a day.

> I’m a bit surprised that the connection pool isn’t purged during this time.

Postgres doesn't really think that killing connections is part of its
charter. (There is idle_in_transaction_session_timeout, but that's
there to guard against a specific performance issue, not to kill
non-misbehaving sessions.)

You should probably think about putting a connection pooler such as
pgbouncer in front of your server. That's a better idea for lots of
low-resource-demand clients than giving them direct server connections.
And I think you're more likely to find features for killing idle
connections there, too.

Another idea, if you suspect that the idle connections are caused
by firewall timeouts or the like, is to enable more aggressive
TCP keepalive checking, to ensure the server notices if a client
isn't there at all anymore. See the tcp_keepalives_* settings.

regards, tom lane

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Bee.Lists 2020-06-23 01:57:44 Re: Connections Increasing Slowly
Previous Message Bee.Lists 2020-06-22 19:43:09 Connections Increasing Slowly