My information is not up to date -- I looked into this a year or so ago.

With the prefork MPM, connection pooling is a problem because of the way the Apache process model works. With a threaded MPM, the situation is different. I think the preferred approach (and I don't know how well it works) is to use a pool of worker threads, each with its own $dbh. If you have a pure Perl application running in mod_perl, you can probably use a threaded MPM with impunity. Otherwise your mileage may vary.

d

Colin Wetherbee wrote:
Mag Gam wrote:
Is it possible to do database connection pooling with mod_perl?

Currently, all of my source code has a my $dbh. Is it possible to have my database stuff in a pool, and I just include it somehow?

DBI::Pool is a partially complete module for doing this. Tim Bunce and Stas Bekman (I think?) have been working on it, on and off [1]. From Tim's DBI road map [2]:

"Connection pooling in a threaded application, such as mod_perl, is difficult because DBI handles cannot be passed between threads. An alternative mechanism for passing connections between threads has been defined, and an experimental connection pool module implemented using it, but development has stalled."

If anyone has any more recent information on DBI::Pool or related efforts, I'd be interested in it, too.

Colin

[1] http://www.nntp.perl.org/group/perl.dbi.dev/2007/04/msg4952.html
[2] http://search.cpan.org/~timb/DBI/Roadmap.pod


Reply via email to