Skip site navigation (1) Skip section navigation (2)

Re: Pooling in Core WAS: Need help in performance tuning.

From: Scott Carey <scott(at)richrelevance(dot)com>
To: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, Kevin Grittner<Kevin(dot)Grittner(at)wicourts(dot)gov>, Greg Smith <greg(at)2ndquadrant(dot)com>, Matthew Wakeling <matthew(at)flymine(dot)org>, Brad Nicholson <bnichols(at)ca(dot)afilias(dot)info>,"pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: Pooling in Core WAS: Need help in performance tuning.
Date: 2010-07-18 19:00:11
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-performance
On Jul 9, 2010, at 8:33 PM, Craig Ringer wrote:

> On 10/07/2010 9:25 AM, Josh Berkus wrote:
>>> It *is* the last place you want to put it, but putting it there can
>>> be much better than not putting it *anywhere*, which is what we've
>>> often seen.
>> Well, what you proposed is an admission control mechanism, which is
>> *different* from a connection pool, although the two overlap.  A
>> connection pool solves 4 problems when it's working:
>> a) limiting the number of database server processes
>> b) limiting the number of active concurrent queries
>> c) reducing response times for allocating a new connection
>> d) allowing management of connection routes to the database
>> (redirection, failover, etc.)
> I agree with you: for most Pg users (a) is really, really important. As 
> you know, in PostgreSQL each connection maintains not only general 
> connection state (GUC settings, etc) and if in a transaction, 
> transaction state, but also a query executor (full backend). That gets 
> nasty not only in memory use, but in impact on active query performance, 
> as all those query executors have to participate in global signalling 
> for lock management etc.
> So an in-server pool that solved (b) but not (a) would IMO not be 
> particularly useful for the majority of users.
> That said, I don't think it follows that (a) cannot be solved in-core. 
> How much architectural change would be required to do it efficiently 
> enough, though...

a, b, and c can all be handled in core.  But that would be a radical re-architecture to do it right.  Postgres assumes that the client connection, authentication, and query processing all happen in one place in one process on one thread.  Most server software built and designed today avoids that model in order to decouple its critical resources from the # of client connections.  Most server software designed today tries to control its resources and not let the behavior of clients dictate resource usage.

Even Apache HTTPD is undergoing a radical re-design so that it can handle more connections and more easily decouple connections from concurrent processing to keep up with competitors.

I'm not saying that Postgres core should change -- again thats a radical re-architecture.  But it should be recognized that it is not like most other server applications -- it can't control its resources very well and needs help to do so.  From using a connection pool to manually setting work_mem differently for different clients or workloads, resource management is not what it does well.  It does a LOT of things very very well, just not that.

> --
> Craig Ringer
> -- 
> Sent via pgsql-performance mailing list (pgsql-performance(at)postgresql(dot)org)
> To make changes to your subscription:

In response to

pgsql-performance by date

Next:From: Tatsuo IshiiDate: 2010-07-19 02:16:04
Subject: Re: Pooling in Core WAS: Need help in performance tuning.
Previous:From: Rajesh Kumar MallahDate: 2010-07-18 18:36:24
Subject: Re: Pooling in Core WAS: Need help in performance tuning.

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group