I have a chat room for a Rails app is implemented the old-fashioned way, using Ajax Polling. This is not scaling, and it is cluttering my log, so I want to reimplement using either EventMachine + HTML5 websocket/degrade to flash, or Node.js. Given that the rest of the app is in Rails, what are the the pros and cons of each of these two alternatives?

This question came from our site for professional and enthusiast programmers. Votes, comments, and answers are locked due to the question being closed here, but it may be eligible for editing and reopening on the site where it originated.

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.
If this question can be reworded to fit the rules in the help center, please edit the question.

This appears to be a better match for programmers: inspire answers that explain “why” and “how”. check tend to have long, not short, answers. probably check have a constructive, fair, and impartial tone. should be, yes invite sharing experiences over opinions. you really would like that here insist that opinion be backed up with facts and references. duh. are more than just mindless social fun. well you are writing a chat server :p ... anyways, I say this is a better fit there, because you're discussing architecture more than anything.
–
jcolebrandAug 29 '11 at 17:33

of additional note, we've just started a project on github for StackChat as part of the recent #NodeKnockout 2011 competition so that may be of use to you.
–
jcolebrandAug 29 '11 at 17:38

1

Dan, what problems are you running into with your current implementation that you're hoping to solve with other approaches?
–
Anna Lear♦Aug 29 '11 at 17:38

4 Answers
4

I only just started to play with Node.js, but I have experience as a Ruby programmer, and have been delving deeper into EM, a lot lately, I will admit if you don't have a lot of experience with it or the reactor pattern it will have a bit of a learning curve from your normal synchronous ruby code. With node.js out of the box it has some great tools for running everything asynchronously.

Or you can alway go a little be easier, and use a simple prebuilt system for handling pubsub sort of jobs like a chat room, and use Faye http://faye.jcoglan.com/ which you run as a separate Rack app using Thin as a server... or if you like this approach, but don't want to manage Faye, you can use an external service like Pusher http://pusher.com/ which expose API's for you do do real time messaging.

Even though you would be introducing something outside the normal rails, I would consider node.js or Erlang for this. Erlang will also scale like nobody's business for this sort of thing. Erlang isn't as good for some of the other web app stuff though, sticking with rails for that is a good call.

I would use Node.js. Considering the amount of fame Node.js and Socket.io have been gaining in the recent days, I can say that it will stay for a long while. Its really easy to learn and program, somewhat easier to debug than EventMachine. Lastly the huge usage and community ensures that it pretty much works on every browser and OS. This is a big plus for me as I spend days solving mundane IE bugs because of the way out application was written.

At the moment I will be Weary of using HTML 5 in an applications used by 100's of people cause not every one uses the latest browser.