[CDBI] mysql connections

David Baird lists.riverside at gmail.com
Thu Sep 22 12:45:19 BST 2005

On 9/22/05, Thomas Klausner <domm at zsi.at> wrote:
> Hi!
> Sorry to bring up this issue again, but I'm not sure what the current state
> of affairs is regarding this issue:
> I have a rather big CDBI based application runnning on a server I have
> nearly no access rights to. The sysadmins complain that the app is using to
> much connections to the MySQL DB.
> It's a fairly standard CDBI setup running with mod_perl and Apache::DBI.
> Do I need to add a custom db_Main method as described here
>   http://wiki.class-dbi.com/index.cgi?UsingWithModPerl
> to get the mysql connection numbers down?
> Or are there any other ways to properly share one connection to mysql in all
> Apache children?
> Is it in fact advisable to share one connection?
> Thanks!

You're not sharing one connection among children. You're ensuring that
each child maintains its own permanent connection.

If you're running multiple vhosts, which are running different
applications, you're getting a separate connection, per
vhost/application, per child. Mounts up fast.

If only some of the Apache children are servicing requests to your app
(others to other vhosts, or idle), you've got lots of unused
connections hanging around.

Since it's MySQL, try running without Apache::DBI. The connections are
built and disposed of very quickly, you might not notice any
difference, but your sysadmins probably will.


More information about the ClassDBI mailing list