pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Paul Lindner <lindner@inuus.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Paul Lindner <lindner@inuus.com>
Cc: Oliver Jowett <oliver@opencloud.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Prepared Statements vs. pgbouncer
Date: Sat, 29 Sep 2007 00:21:59 -0700
Message-ID: <20070929072159.GI3140@inuus.com> (raw)
In-Reply-To: <24584.1191033096@sss.pgh.pa.us>
References: <20070929002513.GG3140@inuus.com>
	<46FDA4F2.8080507@opencloud.com>
	<20070929021522.GH3140@inuus.com>
	<24584.1191033096@sss.pgh.pa.us>

I appear to have stirred the pot a little too vigorously..  Let's take
a deep breath and take a step back..

First off, I really appreciate the hard work that's gone into the
design and implementation of Postgres and the JDBC driver.  I realize
that what I'm trying to do falls outside of the norms -- hopefully the
following background information will help everyone understand what
I'm trying to achieve:

The environment:

 * 100s of application servers using Torque and DBCP
 * Dozens of databases.
 * All app servers can connect to all databases.
 * Each application server may need many connections to an individual
   database.
 * App code as written will spawn multiple concurrent SELECTs to
   a single database to speed up queries on partitioned tables.

Okay..  So given those parameters we've been able to tune the system
to use about 2000 maxconns on the DBs, and a max of 8 connections from
each application server.

In spite of that the majority of connections are idle.  So we kill off
idle backends with cron..  Not ideal, but it's worked so far.. 

Okay... now let's double or triple the number of application servers..
That means either:
  1. Going to 4k or 6k backend maxconns.
  2. Halving or thirding the number of simultaneous conns for each app server.
  3. Use pgbouncer to allow 6k connections while actually
     lowering the number of DB backends, plus giving us some very cool
     maintenance features like redirecting connections to other hosts
     and more.

So we we're trying to implement #3.

If others have better ideas I'm all ears.

Our pgbouncer config will keep a connection on the same backend
for the duration of an individual transaction.

The only thing holding us back from deploying the pgbouncer solution
is this issue with the server-side prepared statements.  

Possible solutions:

 * Use protocolVersion=2, since 7.3 does not support server side prepare..
 * Modify jdbc driver to use unique prefixes for server-side 
   prepared statements.  Build my own jar and deploy.
 * Request help to solve this the 'correct' way.


I realize that this environment is not so common.  All I ask is help
in making it possible.

FWIW it seems that Oracle has something similar in 11g named DRCP:

  http://www.oracle.com/technology/tech/oci/pdf/oracledrcp11g.pdf

So maybe it's not such an uncommon case after all...

Thanks in advance for any assistence, pointers, tips on this matter.


On Fri, Sep 28, 2007 at 10:31:36PM -0400, Tom Lane wrote:
> Paul Lindner <lindner@inuus.com> writes:
> > It seems that the driver should immediately deallocate the server-side
> > prepared statements it creates for cursors when it finishs fetching
> > data for that cursor.
> 
> What exactly is the argument here?  That no client should use anything
> more than the fraction of the FE/BE protocol that pgbouncer currently
> supports?  Pardon me for not buying into it.
> 
> 			regards, tom lane

-- 
Paul Lindner        ||||| | | | |  |  |  |   |   |
lindner@inuus.com

view thread (48+ messages)  latest in thread

Message-ID: <20070929072159.GI3140@inuus.com>
Permalink:  ../20070929072159.GI3140@inuus.com/
Also on:    postgresql.org/message-id/20070929072159.GI3140@inuus.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-jdbc@postgresql.org
  Cc: lindner@inuus.com, tgl@sss.pgh.pa.us, oliver@opencloud.com
  Subject: Re: Prepared Statements vs. pgbouncer
  In-Reply-To: <20070929072159.GI3140@inuus.com>
  References: <20070929002513.GG3140@inuus.com> <46FDA4F2.8080507@opencloud.com> <20070929021522.GH3140@inuus.com> <24584.1191033096@sss.pgh.pa.us> <20070929072159.GI3140@inuus.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