Right now we have a large perl application that is using raw DBI to connect to MySQL and execute SQL statements. It creates a connection each time and terminates. Were starting to approach mysql's connection limit (200 at once)
It looks like DBIx::Connection supports application layer connection pooling.
Has anybody had any experience with DBIx::Connection
?. Are there any other considerations for connection pooling?
I also see mod_dbd
which is an Apache mod that looks like it handles connection pooling.
http://httpd.apache.org/docs/2.1/mod/mod_dbd.html
Just making sure: you know about
DBI->connect_cached()
, right? It's a drop-in replacement forconnect()
that reuses dbh's, where possible, over the life of your perl script. Maybe your problem is solvable by adding 7 characters :)And, MySQL's connections are relatively cheap. Running with your DB at
max_connections=1000
or more won't by itself cause problems. (If your clients are demanding more work than your DB can handle, that's a more serious problem, one which a lowermax_connections
might put off but of course not solve.)I don't have any experience with DBIx::Connection, but I use DBIx::Connector (essentially what DBIx::Class uses internally, but inlined) and it's wonderful...
I pool these connections with a Moose object wrapper that hands back existing object instances if the connection parameters are identical (this would work the same for any underlying DB object):