Re: [Golang-DC] Connection pools

From: Michael L.
Sent on: Monday, September 3, 2012 11:47 AM
I like the idea - and having the connection pool separate from the other packages lets you reuse it nicely. We've had to implement and tweak these for several different libraries. The biggest problem we found is detecting and cleaning up connections that get hosed somehow. This may be more of an issue on Windows (and .Net) than Linux, but you might consider adding some way to detect and reset a bad connection.

Thanks for sharing this.

Mike

On Tue, Aug 28, 2012 at 7:48 PM, Ryan Day <[address removed]> wrote:
Hey everybody!

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 datastore.

I've got a gist here https://gist.github.com/3504674 and an example implementation here https://gist.github.com/3504712. 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)!



Ryan




--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Ryan Day ([address removed]) from Golang DC.
To learn more about Ryan Day, visit his/her member profile
Set my mailing list to email me As they are sent | In one daily email | Don't send me mailing list messages

Meetup, PO Box 4668 #37895 New York, New York[masked] | [address removed]

Our Sponsors

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy