addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscontroller-playcredit-cardcrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobe--smallglobegmailgooglegroupshelp-with-circleimageimagesinstagramFill 1launch-new-window--smalllight-bulblinklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonprintShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruserwarningyahoo

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.


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 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)!


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]

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