I have been using a couple different packages for communicating with
MySQL and Redis, and I've found that the packages I've seen have a
single connection to the server, which is a significant bottleneck
if your application is parallel(I'm dealing with web connections).
I came up with an abstract ConnectionPool which allows you to create
N connections to your datastore, and retrieve a connection from a
pool. You can use that connection as long as necessary, then return
it to the pool. I found this to be much easier than forking and
modifying each package in your codebase that connects to a
I've got a gist here
and an example implementation here
The implementation is taken from our codebase and is for MySQL
database connections. We put this into production just today. So I
figured I'd share it and see if there are any comments, or maybe
somebody sees a huge gotcha that I am totally overlooking.
Anyway, thanks for any advice or tips (or other packages where I
don't recreate the wheel)!