perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Peters <mpet...@plusthree.com>
Subject Re: best practie for open and close connection database
Date Wed, 21 Apr 2010 16:37:47 GMT
On 04/21/2010 12:33 PM, Felipe de Jesús Molina Bravo wrote:

> In my application, I opened my database from authentication handler and
> close it from child exit handler. It is correct (is a best practice)? or
> is a bad design?

Typically it's best practice to not close DB handles. That's why 
Apache::DBI is such a popular module since it handles all of connection 
caching for you.

With some databases (I'm looking at you Oracle) it's expensive to create 
a new database connection so it's more important. With others (like 
MySQL) it's really cheap so there's not a big penalty for not caching.

There are some cases where caching connections is actually a bad thing: 
If you have too many application servers where each has a connection to 
your database and thus overwhelms your database with too many 
connections even though the actual load isn't overloading. But most 
people in this situation will use a proxy like DBD::Gofer to manage the 
DB connections.

-- 
Michael Peters
Plus Three, LP

Mime
View raw message