Re: Connection Pooling
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
Re: Connection Pooling
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
Re: Connection Pooling
On Nov 24, 2007 9:45 PM, Mag Gam <[EMAIL PROTECTED]> wrote: > Is it possible to do database connection pooling with mod_perl? There are options. Are you getting close to the maximum connection your database can handle? You should be running a reverse proxy in front of your mod_perl server, which typically cuts the number of mod_perl processes, and thus database connections, by a factor of 10. If you have a reverse proxy, and still have too many connections, you can look at either SQL Relay or the DBI::Gofer stuff in the latest DBI releases. DBI::Gofer was created to solve the issue of too many connections for Shopzilla.com. - Perrin
Re: Connection Pooling
Perrin Harkins wrote: If you have a reverse proxy, and still have too many connections, you can look at either SQL Relay or the DBI::Gofer stuff in the latest DBI releases. DBI::Gofer was created to solve the issue of too many connections for Shopzilla.com. DBD::Gofer looks like an excellent solution for this problem. I have been putting off some development because I didn't want to write my own pooling server. Thanks for the suggestion. Colin
Re: Connection pooling in Apache2
On Fri, 2005-12-02 at 19:34 +0100, Tom Schindl wrote: > just because I came across it are there any plans to use > mod_dbd-connection of Apache-2.2? Never heard of this before, but it looks like a replacement for DBI, so you'd probably have to rewrite all of your DBI code to use it. - Perrin
Re: Connection pooling in Apache2
Perrin Harkins wrote: On Fri, 2005-12-02 at 19:34 +0100, Tom Schindl wrote: just because I came across it are there any plans to use mod_dbd-connection of Apache-2.2? Never heard of this before, but it looks like a replacement for DBI, so you'd probably have to rewrite all of your DBI code to use it. - Perrin I think he might be inquiring about PERL glue code as part of mod_perl2 I've seen other people on (users|dev)@httpd.a.o and ask this and interestingly, they've pointed to mod_perl/perl folks as the first people to provide language bindings. Though as Perrin says, you wouldn't be able use DBI with it. It would be its own API. -- "Love is not the one you can picture yourself marrying, but the one you can't picture the rest of your life without." "It takes a minute to have a crush on someone, an hour to like someone, and a day to love someone, but it takes a lifetime to forget someone..." Philip M. Gollucci ([EMAIL PROTECTED]) 301.254.5198 Consultant / http://p6m7g8.net/Resume/resume.shtml Senior Software Engineer - TicketMaster - http://ticketmaster.com
Re: Connection pooling in Apache2
Would that necesarily be the case? If mod_dbd is just providing the connection pooling, would it be possible to write a mod_perl2 adapter/subclass/driver to let DBI pull it's connections out of that pool? Adam K Perrin Harkins wrote: On Fri, 2005-12-02 at 19:34 +0100, Tom Schindl wrote: just because I came across it are there any plans to use mod_dbd-connection of Apache-2.2? Never heard of this before, but it looks like a replacement for DBI, so you'd probably have to rewrite all of your DBI code to use it. - Perrin
Re: Connection pooling in Apache2
On Sat, 2005-12-03 at 19:32 +1100, Adam Kennedy wrote: > If mod_dbd is just providing the connection pooling, would it be > possible to write a mod_perl2 adapter/subclass/driver to let DBI pull > it's connections out of that pool? I think that's a question for someone who is deeply familiar with the internals of DBI. The dbi-users list would be a good place to start. - Perrin