Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VDVJx-0008UZ-LG for pgsql-admin@arkaria.postgresql.org; Sun, 25 Aug 2013 08:05:13 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VDVJw-0002Uc-Vn for pgsql-admin@arkaria.postgresql.org; Sun, 25 Aug 2013 08:05:13 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VDVJu-0002TB-FC for pgsql-admin@postgresql.org; Sun, 25 Aug 2013 08:05:10 +0000 Received: from mail-ie0-x22a.google.com ([2607:f8b0:4001:c03::22a]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VDVJr-0007Lq-7R for pgsql-admin@postgresql.org; Sun, 25 Aug 2013 08:05:09 +0000 Received: by mail-ie0-f170.google.com with SMTP id 17so3403105iea.29 for ; Sun, 25 Aug 2013 01:05:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=user-agent:date:subject:from:to:cc:message-id:thread-topic :in-reply-to:mime-version:content-type:content-transfer-encoding; bh=cGHo3uTvCh7RJdGrtdxSL+aw5XuLYuwMZOHOvjyi7Rg=; b=goXxRgM5Xx5KLdL0xUpjOJvBQzfrI12+CFGwFabcz0iRE2v4ERFBraM6pSqDfKGft3 yRxcfnrcfAV0gsFTCulc9IOgxoKhMcxDZ47qWhCIThkwF1Mnz5HrlVKIVecbM0975e8S 0EJC9DvY2tMU4/0pCekws8feYUolPQt0/grZKvR+Fq9tcLmwaFUMBkB84qruZ1xV5VuZ SZFdCKZdvLpTFZ7H17QvVKu+GGiQAYUK6bDslECoPumjqYE2gkqz2JXXCYQ6Hpvfc+lQ e5dCZM50Feqvgi/16rdvp958uBUj8bCu/Qya1ZZMZSfV26rlv97ZIR7uh/7etL0rqi3v E6Lg== X-Received: by 10.50.39.51 with SMTP id m19mr3071414igk.51.1377417906044; Sun, 25 Aug 2013 01:05:06 -0700 (PDT) Received: from [10.8.1.62] (40.166.255.173.client.static.strong-in91.as13926.net. [173.255.166.40]) by mx.google.com with ESMTPSA id ft2sm9865915igb.5.1969.12.31.16.00.00 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 25 Aug 2013 01:05:05 -0700 (PDT) User-Agent: Microsoft-MacOutlook/14.2.3.120616 Date: Sun, 25 Aug 2013 11:04:57 +0300 Subject: Re: postgres crashes on insert in 40 different threads From: Dzmitry To: Scott Ribe CC: Message-ID: Thread-Topic: [ADMIN] postgres crashes on insert in 40 different threads In-Reply-To: <2A3A3AC7-5C4A-411E-B13C-E40A55D0CEF0@elevated-dev.com> Mime-version: 1.0 Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit X-Pg-Spam-Score: -0.1 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-admin Precedence: bulk Sender: pgsql-admin-owner@postgresql.org Ok,thank you, it's a good point. Need to review & make fixes with what I have. Thanks, Dzmitry On 8/24/13 6:14 PM, "Scott Ribe" wrote: >On Aug 19, 2013, at 9:55 AM, Dzmitry wrote: > >> No, I am not using pgbouncer, I am using pgpool. >> >> Total - I have 440 connections to postgres(I have rails application >> running on some servers - each application setup 60 connections to DB >>and >> keep if forever(until will not be killed), also I have some machines >>that >> do background processing, that keep connections too). >> >> Part that do a lot of writes(that update jobs from xml feed every >>night) - >> have 40 threads and keep 40 connections. > >That's extreme, and probably counter-productive. > >How many cores do you have on those rails servers? Probably not 64, >right? Not 32? 16? 12? 8, even? Assuming <64, what advantage do you >expect from 60 connections? Same comment applies to the 40 connections >doing the update jobs--more connections than cores is unlikely to be >helping anything, and more connections than 2x cores is almost guaranteed >to be worse than fewer. > >Postgres connections are of the heavy-weight variety: process per >connection, not thread per connection, not thread-per core event-driven. >In particular, I'd worry about work_mem in your configuration. You've >either got to set it really low and live with queries going to disk too >quickly for sorts and so on, or have it a decent size and have the risk >that too many queries at once will trigger OOM. > >Given your configuration, I wouldn't even start with pgbouncer for >connection pooling. I'd first just slash the number of connections >everywhere by 1/2, or even 1/4 and see what effect that had. Then as a >second step I'd look at where connection pooling might be used >effectively. > >-- >Scott Ribe >scott_ribe@elevated-dev.com >http://www.elevated-dev.com/ >(303) 722-0567 voice > > > > -- Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-admin