Production quality Rails 4 chat demo?

Hi Everyone,

I’m trying to use Rails 4’s ActionController::Live functionality to do a chat-like interface in my app. I’ve found a number of blog posts, all of which seem to be based on Aaron Patterson’s original one here:

Has anyone here successfully gotten this to work well enough for production? I assume that if it is included in Rails 4, there must be some way to get it to work.

I’ve run into two problems (at least!) and I see many comments about these problems, but it’s hard to tell what the definitive solution is.

I created a really trivial chat application for testing. It just ajaxes anything the user types to the server, then uses redis and ActionController:Live to push it to all clients.

My problems:

  1. All I have to do to crash the server is to refresh the web page repeatedly. Something is holding onto the connection, so I can trivially give myself a DOS.

  2. There is a timeout on the connection, so that if I leave the webpage up idling for a while, then it stops reacting to new events.

I have my own server, so I have flexibility in how I set it up. It is currently using Apache/Passenger. I’d prefer to use that simply because I have experience with it, but I’d be willing to change to a different server configuration.