pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alex Adriaanse <alex@innovacomputing.com>
To: Scott Marlowe <scott.marlowe@gmail.com>
Cc: pgsql-general@postgresql.org
Subject: Re: Out of memory
Date: Fri, 28 Mar 2008 16:20:01 -0500
Message-ID: <47ED6101.2060907@innovacomputing.com> (raw)
In-Reply-To: <dcc563d10803281331u2d31d35j3c944d2e98561c64@mail.gmail.com>
References: <47ED3B41.80305@innovacomputing.com>
	<dcc563d10803281331u2d31d35j3c944d2e98561c64@mail.gmail.com>

Scott Marlowe wrote:
> Just because you can set max_connections to 2000 doesn't mean it's a
> good idea.  If your client needs 1000 persistent connections, then put
> a connection pooler between your app (I'm guessing php since it
> operates this way) and the database.
>
> Running 1000 connections is a LOT, and you need 1000 active
> connections, then you're likely gonna need a bigger machine than one
> with 8 cores and 16 gig of rams.  OTOH, if you are actively servicing
> less than 10% of those connections at a time, then you're wasting
> memory on the number of backends that are started up and doing
> nothing.  each one consumes some amount of memory on its own, usually
> in the 5 to 10 meg range, just to sit there and do nothing.
>
> Plus you've got issues with thundering herd type situations that can
> show up as you increase connections.
>
> Pooling is the answer here.
>   
Thanks for the suggestion.  I fully agree with you, and the client is 
already making plans to move from persistent connections to connection 
pooling (they will probably use PgBouncer).  I'm just trying to figure 
out the exact cause of this memory issue so that we can make sure it 
doesn't happen again, even after they switch to connection pooling.  
According to my rough calculations, if the server were to max out at 
2,000 connections there should still be around 2GB of memory free - 
unless all of them were running active queries which is doubtful since I 
did not see unusual changes in the load patterns.  And from what I could 
tell, the server did not tap into swap when PostgreSQL ran out of memory.

Thanks,

Alex




view thread (58+ messages)  latest in thread

Message-ID: <47ED6101.2060907@innovacomputing.com>
Permalink:  ../47ED6101.2060907@innovacomputing.com/
Also on:    postgresql.org/message-id/47ED6101.2060907@innovacomputing.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: alex@innovacomputing.com, scott.marlowe@gmail.com
  Subject: Re: Out of memory
  In-Reply-To: <47ED6101.2060907@innovacomputing.com>
  References: <47ED3B41.80305@innovacomputing.com> <dcc563d10803281331u2d31d35j3c944d2e98561c64@mail.gmail.com> <47ED6101.2060907@innovacomputing.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox