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 1l8SjK-0004LV-TF for pgsql-general@arkaria.postgresql.org; Sat, 06 Feb 2021 18:54:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l8Sio-0002D9-45 for pgsql-general@arkaria.postgresql.org; Sat, 06 Feb 2021 18:54:18 +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 1l8Sin-0002D0-Li for pgsql-general@lists.postgresql.org; Sat, 06 Feb 2021 18:54:17 +0000 Received: from mail-oo1-xc2a.google.com ([2607:f8b0:4864:20::c2a]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1l8Sik-00011K-Cm for pgsql-general@lists.postgresql.org; Sat, 06 Feb 2021 18:54:16 +0000 Received: by mail-oo1-xc2a.google.com with SMTP id 123so2480179ooi.13 for ; Sat, 06 Feb 2021 10:54:14 -0800 (PST) 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=73tSY6G4geZ8GP9v8IuAT8oyrQhBqeCgg0C/E4hKcRc=; b=U2AXI/2Evu2ajwefmvHhpDj3fQcw+9Q7xu9xiBlWoBJ/ehkREqe8Binu9MjbbZukX8 XF/Q75hv0Xp2qBu7pQFnC/6lpO1j4QZHrz4TU2Aoe6PZeFSjncubdB4qe7THaw7BbCBK ptp0osTlynmBDgIVOld2EyhU1bp1l6WNf11mHtCMmPAqji+rhktn86CC/28NhgObOWO7 O+jBf3vtaDwXn0zcLZLZhFKe57NjjktYBmeK50icUPcfirEc5zy/RPuP7zPZhbV7OTt0 1Hvj70lEXthIX3M75nuvRVnvr9/s/w9RUo3bWxv8VhcKvcfasZu1/Chm0lilrXNzen8J UvxA== 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=73tSY6G4geZ8GP9v8IuAT8oyrQhBqeCgg0C/E4hKcRc=; b=WMQKCoXXRWEa3xE3nkvaDzClv93vHama0Odf2F0tpkE33qzOOX+lFcwe5ICLVawiMl RBtSTNAjrfNnaLTUYvE66pqtyrCnN2Ygr7mze1L4mlcbamXhlUiIFqKJJwzqK8pULZky WRS+PdIT0mV9DelKtYHA/t6CvlioYHJ8HrmT1baPa2Exe0lTCW/zSm9JhFEbKWC0h1w3 W1Tk5xkfDjTD3JYy1j/Ifa2fSr6b7LcEDb+ry1QHC2vf6ze6z7pyZ3OcLwznDzd/ZOCh b/k9SS4d7Z9LFoE7ri9iDS2fexA4s2+ES1kw9HPSpKG3XA/kgsxhhnjUqT8U0DJclTGL BoXg== X-Gm-Message-State: AOAM533vfWRPqwEnFq4ZNY5SvGwBQ6mShByqYXQS68zcFbeuC1UiVYvj XoQs6++R8Zg9QPVHYystJpggsyiiGYDR6A== X-Google-Smtp-Source: ABdhPJymD9KlJr2g9ATaSGA0nDrT/O/FVNg3GYqwcNGN9wwm1e2eehFyfV/Sw3FIsSiP7KftvWvj4Q== X-Received: by 2002:a4a:a745:: with SMTP id h5mr7619652oom.21.1612637652816; Sat, 06 Feb 2021 10:54:12 -0800 (PST) Received: from [192.168.88.10] (ip174-67-141-204.no.no.cox.net. [174.67.141.204]) by smtp.googlemail.com with ESMTPSA id 94sm2680112otf.41.2021.02.06.10.54.11 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 06 Feb 2021 10:54:11 -0800 (PST) Subject: Re: vacuumdb not letting me connect to db To: "pgsql-general@lists.postgresql.org" References: <367051164.1780361.1612460095810@mail.yahoo.com> <9645df52-2cdc-9e9e-b43c-d388c1aa7951@gmail.com> <0f3e4fa7-b028-f277-b3d2-114731a6c223@gmail.com> <7e35e59f-364a-eb98-43ac-6c927d8757b4@gmail.com> <2FF4F45A-01AA-4AC5-9EFA-8CE6DCADA9C8@pendari.org> From: Ron Message-ID: <2a5e2391-a627-fb3b-001e-ec75f8267e10@gmail.com> Date: Sat, 6 Feb 2021 12:54:11 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------F991EA1057B5CFC260EFFDFA" 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. --------------F991EA1057B5CFC260EFFDFA Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 2/6/21 6:06 AM, Atul Kumar wrote: > Hi Gavan, > > Thanks for providing the details, I need more clarification on this as how > should I analyze that what should be ideal no. of connections should we > set to avoid IO overhead based on the available hardware resources. > How to do this calculation ? > Run "iotop -o -u postgres", and then compare that with the total bandwidth available to the system.  If it's (even almost) saturated, then everything else will be starved. The "--jobs=" value should AT MOST be some *small* multiple of the number of CPUs (like 1x, 1.5x or *maybe* 2x if the core count is low, and nothing else is running on the system. > Note: even during 300 threads, my RAM utilisation is totally normal. > > > Regards > Atul > > > > > > > On Saturday, February 6, 2021, Gavan Schneider > wrote: > > On 6 Feb 2021, at 3:37, Ron wrote: > > On 2/5/21 10:22 AM, Rob Sargent wrote: > > > > On 2/5/21 9:11 AM, Ron wrote: > > Obviously... don't use 300 threads. > > No, no Ron.  Clearly the answer is more CPUs > > > I hope you're being sarcastic. > > A reasonable conjecture… though there is the consideration that 300 > CPU intensive tasks spread across a given number of CPUs is going to > waste some resources with context switching., i.e., need more CPUs :) > > Basically if there is plenty of wait time for I/O completion then CPU > task switching can get more total work done.  So far so obvious. In > this thread I can see where it is disappointing to have a system > considered capable of 700 connections getting saturated by a “mere” > 300 threads. But this is only a “problem” if connections are equated > to threads. PG max connection count is about external users having > access to resources needed to get a task done. Like all resource > allocations this relies on estimated average usage, i.e., each > connection only asks for a lot of CPU in brief bursts and then the > result is transmitted with a time lag before the connection makes > another CPU demand. The system designer should use estimations about > usage and load to budget and configure the system, and, monitor it all > against actual performance in the real world. Of course estimates are > a standing request for outliers and the system will show stress under > an unexpected load. > > So far I have not seen an analysis of where the bottle neck has > occurred: CPU RAM HD and/or the data bus connecting these. Some of > these hardware resources maxed out to the extent the system would not > immediately pick up an additional work unit. As I see it OP started > 300 CPU intensive tasks on hardware intended for 700 connections. If > the connection count was designed with say 50% CPU intensive time per > connection you would expect this hardware to be fully saturated with > 300 CPU intensive tasks. More than that, doing the task with 300 > threads would probably take longer than (say) 200 threads as the > increased CPU context swapping time is just wasted effort. > > OP now has a choice: decrease threads or (seriously) upgrade the > hardware. We in the gallery would love to see a plot of total time to > completion as a function of threads invoked (50-300 increments of 50) > assuming the starting conditions are the same :) > > Gavan Schneider > —— > Gavan Schneider, Sodwalls, NSW, Australia > Explanations exist; they have existed for all time; there is always a > well-known solution to every human problem — neat, plausible, and wrong. > — H. L. Mencken, 1920 > -- Angular momentum makes the world go 'round. --------------F991EA1057B5CFC260EFFDFA Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

On 2/6/21 6:06 AM, Atul Kumar wrote:
Hi Gavan,

Thanks for providing the details, I need more clarification on this as how should I analyze that what should be ideal no. of connections should we set to avoid IO overhead based on the available hardware resources.
How to do this calculation ?


Run "iotop -o -u postgres", and then compare that with the total bandwidth available to the system.  If it's (even almost) saturated, then everything else will be starved.

The "--jobs=" value should AT MOST be some *small* multiple of the number of CPUs (like 1x, 1.5x or maybe 2x if the core count is low, and nothing else is running on the system.

Note: even during 300 threads, my RAM utilisation is totally normal.


Regards 
Atul






On Saturday, February 6, 2021, Gavan Schneider <list.pg.gavan@pendari.org> wrote:
On 6 Feb 2021, at 3:37, Ron wrote:

On 2/5/21 10:22 AM, Rob Sargent wrote:


On 2/5/21 9:11 AM, Ron wrote:
Obviously... don't use 300 threads.

No, no Ron.  Clearly the answer is more CPUs

I hope you're being sarcastic.

A reasonable conjecture… though there is the consideration that 300 CPU intensive tasks spread across a given number of CPUs is going to waste some resources with context switching., i.e., need more CPUs :)

Basically if there is plenty of wait time for I/O completion then CPU task switching can get more total work done.  So far so obvious. In this thread I can see where it is disappointing to have a system considered capable of 700 connections getting saturated by a “mere” 300 threads. But this is only a “problem” if connections are equated to threads. PG max connection count is about external users having access to resources needed to get a task done. Like all resource allocations this relies on estimated average usage, i.e., each connection only asks for a lot of CPU in brief bursts and then the result is transmitted with a time lag before the connection makes another CPU demand. The system designer should use estimations about usage and load to budget and configure the system, and, monitor it all against actual performance in the real world. Of course estimates are a standing request for outliers and the system will show stress under an unexpected load.

So far I have not seen an analysis of where the bottle neck has occurred: CPU RAM HD and/or the data bus connecting these. Some of these hardware resources maxed out to the extent the system would not immediately pick up an additional work unit. As I see it OP started 300 CPU intensive tasks on hardware intended for 700 connections. If the connection count was designed with say 50% CPU intensive time per connection you would expect this hardware to be fully saturated with 300 CPU intensive tasks. More than that, doing the task with 300 threads would probably take longer than (say) 200 threads as the increased CPU context swapping time is just wasted effort.

OP now has a choice: decrease threads or (seriously) upgrade the hardware. We in the gallery would love to see a plot of total time to completion as a function of threads invoked (50-300 increments of 50) assuming the starting conditions are the same :)

Gavan Schneider
——
Gavan Schneider, Sodwalls, NSW, Australia
Explanations exist; they have existed for all time; there is always a well-known solution to every human problem — neat, plausible, and wrong.
— H. L. Mencken, 1920

--
Angular momentum makes the world go 'round.
--------------F991EA1057B5CFC260EFFDFA--