[LRUG] Puma, CLOSE_WAIT. Arg.
jlsync at gmail.com
Thu Feb 18 09:35:00 PST 2016
A long time ago I was using heroku, MRI, puma, and ActionController::Live.
Exceptions would cause database connections to leak, this was a problem for
me because the heroku free tier only gives you 20 database connections and
I was using a db connection on every streaming request in order to use
postresql's listen/notify feature ( instead of using, say, redis pub/sub).
This code https://gist.github.com/jlsync/ea499fa90a9abfe04fa9 manages
database connections by using
to get a connection and then a ruby "ensure" block at the end to "checkin"
the connection back to the pool.
The code also uses
to monitor the active ruby/puma thread count, and also
to monitor database connections.
You can see these monitoring counts being logged directly to the UI here
https://jlquiz.herokuapp.com/ (after logging in).
my puma config included
# worker specific setup
Using some of these ideas might help you.
On Thu, Feb 18, 2016 at 4:01 PM, Simon Morley <simon at polkaspots.com> wrote:
> As an interim update, adding the recommended
> ActiveRecord::Base.connection_pool.disconnect! doesn't seem to help :(
> We're seeing far fewer timeouts but they're still happening on that db
> connection. And when they happen, it's carnage for 15s.
> Simon Morley
> Big Chief | PolkaSpots Supafly Wi-Fi
> Bigger Chief | Cucumber Tony
> Got an unlicensed Meraki? Set it free with Cucumber
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Chat