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 1jLuuw-0005c2-JL for pgsql-general@arkaria.postgresql.org; Tue, 07 Apr 2020 20:33:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jLuuv-0001rL-8K for pgsql-general@arkaria.postgresql.org; Tue, 07 Apr 2020 20:33:53 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jLuuu-0001rE-SO for pgsql-general@lists.postgresql.org; Tue, 07 Apr 2020 20:33:53 +0000 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jLuus-0007rz-Dr for pgsql-general@lists.postgresql.org; Tue, 07 Apr 2020 20:33:51 +0000 Received: by mail-pf1-x436.google.com with SMTP id n10so1341824pff.3 for ; Tue, 07 Apr 2020 13:33:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=m6jPzL0sAOW8gUHMTi69ssPQ46idk5L2R4jX6lULfNI=; b=ZkzDZ9oY2/3BaiTIYweZF5oxEt8bawZVHp2TnPFCArKaXtZJBzCkQCB7ysXoHrZAPA 2RcfxyKhjM0aSVp4VEb2zTKj6o5w4MEEHv6bAAUoi8gw1LY4wFI+I2FFIRyfBP6iUsCR HL+J5T+iEhOZ9aohX/POFazRD2klSe7S7JuyqQ7dmDmXXHWujPg8vV0OHokvBQqXzpEz Uwa62M2O9fEITauxGJFN6xm+UBkqS48FVQjyPXVlEOlRi8qJWEqS1vNh2Mm+L9VLs8Vq dzo0xtC/klLTpselTvMVrkNzKHArtqxg+0CG2HNXop8XF5DCSn4MOBIezstsL94pVhRB 5Dug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=m6jPzL0sAOW8gUHMTi69ssPQ46idk5L2R4jX6lULfNI=; b=P+FWPSy/ht6IXUNQk3h/0za5sQVv8LwS6vKFIzNtFuicTrkIPi+V0K7fk4pTTQxsZW VJwYWi/ILP8ArcBVTbZ6mf0G8ykdpobU0dggI1er+i4b9Z4b6Xn93U6LL+zo4AfucCRb lWIDFO8SPuR/0g0UbhGbxsKJlAdAB3ibedvHdtR+RZacg30SH0HT/YW3tAmNaHpY5xv1 K8Ds0jSX+itmsd4sST4vOQWXJe49rAgZa3CqlXoSb9gv19QMrQtmhtdb8C0vdvw2ET0Y /XHtaKx4bj9Pph8RNNGH+CPjT4Z/ZSZp3KYIv4x5WX90WUJYHOK2W/XGItb7y/fkPqgN akcQ== X-Gm-Message-State: AGi0PuaAJaSqPJ1QyVotZVSMZ5u76caGvBo9jlMiSet/zqZhfNYsBJ/p HtMbCEPymhagtgeB9WQ7B8HrZ8lrNw4= X-Google-Smtp-Source: APiQypIrTWn1oHdv06CZ8rMh7BpDA4yQwWCb3IDJp3S6DkMMwTMT716zigotSp70FeE3LpeEcDgLjw== X-Received: by 2002:aa7:96f8:: with SMTP id i24mr4213449pfq.321.1586291628584; Tue, 07 Apr 2020 13:33:48 -0700 (PDT) Received: from [10.128.51.151] ([155.98.131.7]) by smtp.gmail.com with ESMTPSA id d8sm2347770pjx.12.2020.04.07.13.33.47 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 07 Apr 2020 13:33:48 -0700 (PDT) Subject: Re: Estimated resources for a 500 connections instance (VM) To: pgsql-general@lists.postgresql.org References: <3fd51f3222a35e227484afae34796d3f4f667567.camel@cybertec.at> From: Rob Sargent Message-ID: Date: Tue, 7 Apr 2020 14:31:34 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------B74A8E70B0E6C8B84B2E1142" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------B74A8E70B0E6C8B84B2E1142 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 4/7/20 2:23 PM, Sándor Daku wrote: > On Tue, 7 Apr 2020 at 21:52, David Gauthier > wrote: > > After looking at some of the factors that can affect this, I think > it may be important to know that most of the connections will be > almost idle (in terms of interacting with the DB).  The "users" > are perl/dbi scripts which connect to the DB and spend the vast > majority of the time doing things other than interacting with the > DB.  So a connection is consumed, but it's not really working very > hard with the DB per-se.  I am cleaning up some of that code by > strategically connecting/disconnecting only when a DB > interaction is required.  But for my edification, is it roughly > true that 2 connections working with the DB 100% of the time is > equivalent to 20 connections @ 10% = 200 connections @ 1 % (if you > know what I mean) ? > > > Hi, > > Every open connection consumes a bit of resources witch is not a big > deal if you keeping open a few more connections than you strictly > needed. However when you keeping a few hundred idle connections those > resources add up quickly. So don't do that if it's possible. > Likewise, establishing a new connection is resource costly process. So > don't do that either if it's possible. > Long story short, if those connections don't use many different users > then(as others already suggested) connection pooling will be the best > solution. > > Regards, > Sándor And from my experience pg_bouncer if very easy to include in your stack.  (If not tried pg_pool.) --------------B74A8E70B0E6C8B84B2E1142 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

On 4/7/20 2:23 PM, Sándor Daku wrote:
On Tue, 7 Apr 2020 at 21:52, David Gauthier <davegauthierpg@gmail.com> wrote:
After looking at some of the factors that can affect this, I think it may be important to know that most of the connections will be almost idle (in terms of interacting with the DB).  The "users" are perl/dbi scripts which connect to the DB and spend the vast majority of the time doing things other than interacting with the DB.  So a connection is consumed, but it's not really working very hard with the DB per-se.  I am cleaning up some of that code by strategically connecting/disconnecting only when a DB interaction is required.  But for my edification, is it roughly true that 2 connections working with the DB 100% of the time is equivalent to 20 connections @ 10% = 200 connections @ 1 % (if you know what I mean) ?  

Hi,

Every open connection consumes a bit of resources witch is not a big deal if you keeping open a few more connections than you strictly needed. However when you keeping a few hundred idle connections those resources add up quickly. So don't do that if it's possible.
Likewise, establishing a new connection is resource costly process. So don't do that either if it's possible.
Long story short, if those connections don't use many different users then(as others already suggested) connection pooling will be the best solution.

Regards,
Sándor   
And from my experience pg_bouncer if very easy to include in your stack.  (If not tried pg_pool.)
--------------B74A8E70B0E6C8B84B2E1142--