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 1jM5Ix-0001iJ-FA for pgsql-general@arkaria.postgresql.org; Wed, 08 Apr 2020 07:39:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jM5Iw-0005Aw-B5 for pgsql-general@arkaria.postgresql.org; Wed, 08 Apr 2020 07:39:22 +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 1jM5Iw-0005An-3e for pgsql-general@lists.postgresql.org; Wed, 08 Apr 2020 07:39:22 +0000 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jM5Iu-0004io-0c for pgsql-general@postgresql.org; Wed, 08 Apr 2020 07:39:21 +0000 Received: by mail-wr1-x432.google.com with SMTP id h9so6604544wrc.8 for ; Wed, 08 Apr 2020 00:39:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:cc:date:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=QVj8NFFqe7j48zZcwlXWBw1ZWhnn+X4NY1m3ngDtozE=; b=gW8EtXSVJL1jcSM8b5MaswGRmXVxs6fuwp2EzCiYc2+zgEdDxhygBchnbHDmGKupjU ns3jsOJI19aj30QEbpm7yKA4fn2mjGz+pYqyd22l4VxcWxcpnZ5/DzmjzTzSDn2u3VCa LJCLI8RmJbxgragbMKShnuN7oYm+uuZJQCJomdnVj0xaRh29Om5KO0ZQesWuG8vqW+e4 0EM3mBVBbZ+wAP13V6VsaGCqCAt7E4t5TxDyWRXg8C43GlxQr1Lp70tPTmpfcH57WIdr GEz19Bl+2JILoufCqfZd7fY44AsbzQtrecMQwo8LWQ12TbzMbbqwWE7lI+Lg96vRvWFH yA2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=QVj8NFFqe7j48zZcwlXWBw1ZWhnn+X4NY1m3ngDtozE=; b=GediXuKs4KdWUWM1wA7EmIr6ya/EVumPRHOFq3KSXKopzJSV5ZKWKXtRBIT+ksBZDH pC7ITBlKeODAi+hOJoyvFoSuqcrQWZpa0REOyTE4BT8i+z0RREbpCv0YKapPXgpqcxOM oWAAbnSN8w/2x85i4nrHxEj6g2TxH20LjvD5DvAUDZvlO8aGCBsa87lcoZCNhJnN893W EBqG1By/hU3chx92xnEeWr5LmP0fe4dfn/P/dGPOU5+z1kXc3RCxKK6zICPzEfNYbv2G EgOpc12BXEJCwWJw6zCTiw31+sPfAaqEhAQD2LT34DtMkU9EVs9h2DM9OYJhCKoBbyfw 7V/Q== X-Gm-Message-State: AGi0PubPwl/abJfl9gyaX3uICUrMJrzyIRHYLX/UC7UL1rx1VwRQ9T27 0bWvZEVcfGj5Yv7hc8VHi+2q5W+yjoI= X-Google-Smtp-Source: APiQypIFPOTQDPspxdS6MZq9yTlCfMehgMErwt/jG2UagXObWpaSw8O88sQqs8xwTAgpV+hosYauew== X-Received: by 2002:adf:f54d:: with SMTP id j13mr6614843wrp.28.1586331556718; Wed, 08 Apr 2020 00:39:16 -0700 (PDT) Received: from dynamic-eo9ep2gvk1od1jkp7-pd01.res.v6.highway.a1.net (dynamic-eo9ep2gvk1od1jkp7-pd01.res.v6.highway.a1.net. [2001:871:60:9a24:f742:b269:e6b9:a48b]) by smtp.gmail.com with ESMTPSA id o9sm33918499wrx.48.2020.04.08.00.39.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2020 00:39:16 -0700 (PDT) Message-ID: <61be363b9bb9e3e326bce538e9b5f480bf232103.camel@cybertec.at> Subject: Re: Estimated resources for a 500 connections instance (VM) From: Laurenz Albe To: David Gauthier Cc: Postgres General Date: Wed, 08 Apr 2020 09:39:15 +0200 In-Reply-To: References: <3fd51f3222a35e227484afae34796d3f4f667567.camel@cybertec.at> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.32.5 (3.32.5-1.fc30) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Tue, 2020-04-07 at 15:51 -0400, David Gauthier wrote: > 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) ? Roughly, yes. There is a certain overhead, as each query has to take a snapshot of the database, which has to consider all active connections. But the main problem is that you have no way to ensure that all those idle connections stay idle. Imagine that most of these sessions issue short statements against "table1". There are also some longer SELECTs. No problem so far. Now along comes a statement that blocks the table for a very short time, like a CREATE INDEX CONCURRENTLY. Unfortunately, that ACCESS EXCLUSIVE lock has to wait for one of the longer SELECTs to finish. Now all those moderately short statements cannot run any more, but they have to queue behind the ACCESS EXCLUSIVE lock. For a while, nothing happens. Then, as soon as the CREATE INDEX CONCURRENTLY has got its lock, done its work and finished, all hell breaks loose, because all sessions start executing their statements at the same time. I have seen databases servers go down because of such events, and the problem is the high number of connections, even if they are idle most of the time. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com