Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iAEEL-0007KJ-GF for pgsql-general@arkaria.postgresql.org; Tue, 17 Sep 2019 14:13:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iAEEJ-0000bf-Rt for pgsql-general@arkaria.postgresql.org; Tue, 17 Sep 2019 14:13:19 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iAEEJ-0000bM-F9; Tue, 17 Sep 2019 14:13:19 +0000 Received: from impout003aa.msg.chrl.nc.charter.net ([47.43.20.27] helo=impout003.msg.chrl.nc.charter.net) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1iAEEG-0006Rr-Vl; Tue, 17 Sep 2019 14:13:18 +0000 Received: from cerberus.crazybean.net ([24.151.10.150]) by cmsmtp with ESMTP id AEEFimuc0nJPnAEEFi5pCJ; Tue, 17 Sep 2019 14:13:15 +0000 Authentication-Results: crazybean.net; none X-Authority-Analysis: v=2.3 cv=aafVYigt c=1 sm=1 tr=0 a=D2HTw/M6/8MmcHighGO7rg==:117 a=D2HTw/M6/8MmcHighGO7rg==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=J70Eh1EUuV4A:10 a=pGLkceISAAAA:8 a=fPbKrNlDqR4XX0QkVuIA:9 a=u6DfkxpYkicGKWg5:21 a=OC6XxK8WWdLH4Mo4:21 a=QEXdDO2ut3YA:10 a=tG_4AsI0uXQLnY2m:21 a=U3y0WpWdduGKqOdT:21 a=WAeZA9NQ9_I1DsxG:21 a=_W_S_7VecoQA:10 Received: from [10.25.233.58] (144.121.139.193.lightower.net [144.121.139.193]) by cerberus.crazybean.net (OpenSMTPD) with ESMTPSA id c0537451 (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO); Tue, 17 Sep 2019 10:13:14 -0400 (EDT) From: Rui DeSousa Message-Id: <43F5E11E-9ADA-40F9-B473-4B6B0BD27EF4@crazybean.net> Content-Type: multipart/alternative; boundary="Apple-Mail=_BA0EAF1D-CBEB-40C3-8397-E01075E85FA4" Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: Re: max_connections parameter: too_many_connections error Date: Tue, 17 Sep 2019 10:13:13 -0400 In-Reply-To: Cc: pgsql-general@lists.postgresql.org, pgsql-admin@lists.postgresql.org To: Shital A References: X-Mailer: Apple Mail (2.3445.104.11) X-CMAE-Envelope: MS4wfE/KV3m1jL9VCpo09e2yeATHDcde4pBhxqrTuKvshntgViMCjUVVfajMQzIzyOEJ5eFbpTG9fOhrtENceSzQ/AqFNM4BignxjhFCAqSCbviidOgmt1Qb 0djtgF0BNJI6Po7DIityPhq13PCi/xHA1tRMXJV6NE9sQnYveJgTrX1cN91ESaq2a1DXvr4GqYnuX4OpChMgH2rG/HqoRmjw92jLo8zzFqwuT0yLQt7V8Tc3 nsTLUqdPCJVlSQToP/LRf/FQov47bCZHStkfM3aVJemGNpmDx+S89LoVMd5ksRdW List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Apple-Mail=_BA0EAF1D-CBEB-40C3-8397-E01075E85FA4 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Sep 17, 2019, at 8:43 AM, Shital A = wrote: >=20 > Hello, >=20 > We are working on a payments systems which uses postgreSql 9.6 as = backend DB and blockchain technology. The database is setup in HA in = master-standby mode using pacemaker on Linux 7.6. >=20 > We are new to postgres and need help in deciding how to set value for = max_connections on DB. >=20 > 1. How can we decide on optimal value for max_connections for a given = setup/server? I checked many posts saying that even 1000 is considered = as a very high value but we are hitting the error too_many_connections = due to Max_connections value limit. >=20 I=E2=80=99d say 2x the number you expect to have connect to the database = as you can not change the value without bouncing the service and = downtime is usually hard to come by. Just set the monitoring solution = at 50%. That=E2=80=99s what I currently do; using a max connection of = 2000 with an average connection rate of around 800. That sounds like a = lot but with 96 cores that=E2=80=99s only around 9 connections per core. = =20 > 2. We usee hikari pool on the client side but that even has = limitations. Implementing pg_bouncer is another suggestion in the posts. = In a HA setup, do we have to set it up on both primary standby? >=20 Take a look at pg_bouncer. The problem with a high number of = connections is that the idle connections will wake up from poll() and = spin on the cpu. I=E2=80=99m in the process of testing pg_bouncer to = reduce the number PostgreSQL connections to resolve the high server load = due to idle sessions. pg_bouncer has proven to be effective as it = doesn=E2=80=99t suffer from the idle poll() issue and it has reduced the = server load due to idle sessions.=20 I have been wondering if PostgreSQL used kqueues instead of poll if it = would allow the server to scale better without having to introduce = pg_bouncer. --Apple-Mail=_BA0EAF1D-CBEB-40C3-8397-E01075E85FA4 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

On Sep 17, 2019, at 8:43 AM, Shital A <brightuser2019@gmail.com> wrote:

Hello,

We are working on a payments systems which uses = postgreSql 9.6 as backend DB and blockchain technology. The database is = setup in HA in master-standby mode using pacemaker on Linux 7.6.

We are new to postgres and need = help in deciding how to set value for max_connections on DB.

1. How can we decide on optimal value for = max_connections for a given setup/server? I checked many posts saying = that even 1000 is considered as a very high value but we are hitting the = error too_many_connections due to Max_connections value limit. =

I=E2=80=99d say 2x the number you = expect to have connect to the database as you can not change the value = without bouncing the service and downtime is usually hard to come by. =  Just set the monitoring solution at 50%.   That=E2=80=99s = what I currently do; using a max connection of 2000 with an average = connection rate of around 800.  That sounds like a lot but with 96 = cores that=E2=80=99s only around 9 connections per core. =  

2. We usee hikari pool = on the client side but that even has limitations. Implementing = pg_bouncer is another suggestion in the posts. In a HA setup, do we have = to set it up on both primary = standby?

Take a look at = pg_bouncer.   The problem with a high number of connections is that = the idle connections will wake up from poll() and spin on the cpu. =  I=E2=80=99m in the process of testing pg_bouncer to reduce the = number PostgreSQL connections to resolve the high server load due to = idle sessions.  pg_bouncer has proven to be effective as it = doesn=E2=80=99t suffer from the idle poll() issue and it has reduced the = server load due to idle sessions. 

I have been wondering if PostgreSQL used kqueues = instead of poll if it would allow the server to scale better without = having to introduce pg_bouncer.

= --Apple-Mail=_BA0EAF1D-CBEB-40C3-8397-E01075E85FA4--