Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jnSnJ-0004Fw-SU for pgsql-novice@arkaria.postgresql.org; Mon, 22 Jun 2020 20:11:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jnSnI-0007wY-PQ for pgsql-novice@arkaria.postgresql.org; Mon, 22 Jun 2020 20:11:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jnSnI-0007wR-In for pgsql-novice@lists.postgresql.org; Mon, 22 Jun 2020 20:11:52 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jnSnG-0007rW-HA for pgsql-novice@postgresql.org; Mon, 22 Jun 2020 20:11:52 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 05MKBmTs2088231; Mon, 22 Jun 2020 16:11:48 -0400 From: Tom Lane To: "Bee.Lists" cc: Submit Postgresql Novice Subject: Re: Connections Increasing Slowly In-reply-to: <8A1234E2-D4C3-451F-8F60-901D0D5E0CA5@gmail.com> References: <8A1234E2-D4C3-451F-8F60-901D0D5E0CA5@gmail.com> Comments: In-reply-to "Bee.Lists" message dated "Mon, 22 Jun 2020 15:43:09 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <2088229.1592856708.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 22 Jun 2020 16:11:48 -0400 Message-ID: <2088230.1592856708@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk "Bee.Lists" writes: > Hi folks. My PostgreSQL server has a growing number of connections. = > Currently it=E2=80=99s at 115. max_connections set to 300. It=E2=80=99= s being accessed from public (web application), server cron once a day, an= d two clients on the LAN, a handful of times a day. = > I=E2=80=99m a bit surprised that the connection pool isn=E2=80=99t purge= d 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