On 4/20/05 5:19 PM, "Ian Bicking" <ianb@...> wrote:
>> As I'm running Apache in prefork, each process of it seems to have a few db
>> handles, and they don't seem to be re-used very efficiently causing heavy
>> sqlobject usage to open tons of db connections for each process until I max
>> out the postgres connection limit.
>> I liked with mod_perl, how I could use Apache::DBI and it would intercept
>> every DBI call and re-use idle connection handles, I'm hoping ConnectionHub
>> can be used in a similar fashion with the SQLobject classes?
> Well, SQLObject should be doing the right thing right now. But
> apparently it isn't. Well... maybe ConnectionHub could help you, if you
> find you are recreating connections (via connectionForURI or somesuch)
> -- not that SQLObject connections aren't the same as database
> connections, and they have their own pooling to do the same thing you
> describe with DBI. But if you create a new SQLObject connection every
> request the old ones might stick around with their private pools and do
> what you are encountering. I don't know why they'd stick around and not
> get garbage collected... though I haven't thought about it, and maybe
> when they are garbage collected they don't close the connections in
> their pool, and connections that aren't explicitly closed for some
> databases aren't closed when collected.
Well, the database connections are closed, but it seems to take too long in
some cases. For example, if there's a big spike on the heavy SQLObject
section all at once, it spawns more apache processes to handle the load.
Each apache process appears to have its own database pool, so every time a
new process is created, several new db connections open up. The spike in web
traffic quickly eats up all the free db connections.
Is the connection pool supposed to be shared by the different child apache
processes? Or is this functioning as it was built; that is, each process
when it calls SQLObject, gets its own pool of db connections. If the latter
is the case, how many db connections does each db pool use, and how can I
While having a decent db pool in a process is great if you're running
threaded/async, when each task is handled by another process it gets too
resource inefficient unless multiple processes can share one db pool (as
they seem to with Apache::DBI in mod_perl).