Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id B40F21337B53 for ; Wed, 24 Nov 2010 04:58:29 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 17285-07 for ; Wed, 24 Nov 2010 08:58:22 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-bw0-f46.google.com (mail-bw0-f46.google.com [209.85.214.46]) by mail.postgresql.org (Postfix) with ESMTP id E875F1336B42 for ; Wed, 24 Nov 2010 04:58:21 -0400 (AST) Received: by bwz15 with SMTP id 15so7986881bwz.19 for ; Wed, 24 Nov 2010 00:58:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=vck76q5w3PdZtuVjxbef6QjNdWeYG3AHuFaCEc90Bbo=; b=Z13s0dl4FlozDH2HgqQx0rRzQ4SDCc66n6gLxXl6P/3/EazWBZsTvrdEEJOQuoELyG IzoRzde4vqiqZo2rJZS1nZhF83iZ8+V+Z/hmcVemtw9Cuwr3kVDQfRZwyEld77Q4hC4v r55wjStFbVZtLzLbYV7pKxiKnfBObK+M3YyEQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=FkTvHfyXUGR4RO+VneZuP4u8dEr7gBKW3P/T9/bT9f/6i7ensgLht4lIAH2U9EwSth R2gaRcvlpCvTU2Sp9YtG+Rxdh2V8oWJzZHtfqtgaF/EZkrLprxlSlbGu4nuNXAEDwLs1 /o1nlkdd+nHRN/wCNbg4sRTe2Hv69t7DqL4ro= Received: by 10.204.76.79 with SMTP id b15mr8068528bkk.168.1290589100992; Wed, 24 Nov 2010 00:58:20 -0800 (PST) Received: from [10.1.1.57] (skuns.zoral.com.ua [91.193.166.194]) by mx.google.com with ESMTPS id 11sm780941bkj.12.2010.11.24.00.58.18 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 24 Nov 2010 00:58:18 -0800 (PST) Message-ID: <4CECD3A8.2050707@gmail.com> Date: Wed, 24 Nov 2010 10:58:16 +0200 From: Vitalii Tymchyshyn User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.15) Gecko/20101027 Thunderbird/3.0.10 MIME-Version: 1.0 To: Craig Ringer CC: Ivan Voras , pgsql-performance@postgresql.org Subject: Re: Performance under contention References: <4CE9773D0200002500037CA6@gw.wicourts.gov> <4CEA373D0200002500037CED@gw.wicourts.gov> <4CEC5830.90805@postnewspapers.com.au> In-Reply-To: <4CEC5830.90805@postnewspapers.com.au> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201011/364 X-Sequence-Number: 41388 24.11.10 02:11, Craig Ringer написав(ла): > On 11/22/2010 11:38 PM, Ivan Voras wrote: >> On 11/22/10 16:26, Kevin Grittner wrote: >>> Ivan Voras wrote: >>>> On 11/22/10 02:47, Kevin Grittner wrote: >>>>> Ivan Voras wrote: >>>>> >>>>>> After 16 clients (which is still good since there are only 12 >>>>>> "real" cores in the system), the performance drops sharply >>>>> >>>>> Yet another data point to confirm the importance of connection >>>>> pooling. :-) >>>> >>>> I agree, connection pooling will get rid of the symptom. But not >>>> the underlying problem. I'm not saying that having 1000s of >>>> connections to the database is a particularly good design, only >>>> that there shouldn't be a sharp decline in performance when it >>>> does happen. Ideally, the performance should remain the same as it >>>> was at its peek. >>> >>> Well, I suggested that we add an admission control[1] mechanism, >> >> It looks like a hack (and one which is already implemented by connection >> pool software); the underlying problem should be addressed. > > My (poor) understanding is that addressing the underlying problem > would require a massive restructure of postgresql to separate > "connection and session state" from "executor and backend". Idle > connections wouldn't require a backend to sit around unused but > participating in all-backends synchronization and signalling. Active > connections over a configured maximum concurrency limit would queue > for access to a backend rather than fighting it out for resources at > the OS level. > > The trouble is that this would be an *enormous* rewrite of the > codebase, and would still only solve part of the problem. See the > prior discussion on in-server connection pooling and admission control. Hello. IMHO the main problem is not a backend sitting and doing nothing, but multiple backends trying to do their work. So, as for me, the simplest option that will make most people happy would be to have a limit (waitable semaphore) on backends actively executing the query. Such a limit can even be automatically detected based on number of CPUs (simple) and spindels (not sure if simple, but some default can be used). Idle (or waiting for a lock) backend consumes little resources. If one want to reduce resource usage for such a backends, he can introduce external pooling, but such a simple limit would make me happy (e.g. having max_active_connections=1000, max_active_queries=20). The main Q here, is how much resources can take a backend that is waiting for a lock. Is locking done at the query start? Or it may go into wait while consumed much of work_mem. In the second case, the limit won't be work_mem limit, but will still prevent much contention. Best regards, Vitalii Tymchyshyn