bigpresh / Dancer-Plugin-Database

Dancer::Plugin::Database - easy database support for Dancer applications
http://search.cpan.org/dist/Dancer-Plugin-Database
37 stars 36 forks source link

setting to disconnect at end of request by default? #52

Open msouth opened 10 years ago

msouth commented 10 years ago

I just encountered an issue with an app going into production that had not been sufficiently volume tested. The starman workers were holding their database connections open and exceeded the max number of connections in mysql.

For mysql, in particular, there are people that recommend just reconnecting every time because connections are cheap. It might be nice to have a setting that would call disconnect at the end of a request.

possibly (peripherally) related to #10

bigpresh commented 9 years ago

Firstly, sorry this received no attention for so long

Hmm - in general I'd say the fix is to increase the number of connections to mysql rather than having your app connect and disconnect for every HTTP request - I believe you'll find much better performance.

However - it shouldn't be that difficult to provide a setting that causes an after hook to disconnect the connection, I'd say.