Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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?

share|improve this question

migrated from stackoverflow.com Aug 29 '11 at 17:37

This question came from our site for professional and enthusiast programmers.

    
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. –  jcolebrand Aug 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. –  jcolebrand Aug 29 '11 at 17:38
    
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.

share|improve this answer

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.

Flash, no. Unless you have a lot of flash developers.

share|improve this answer

Rails + EventMachine

Pro

  • It's Ruby

Cons

  • Ruby has poor threading :( It's getting better though, over time

Node.js

Pro

Cons

  • It's Javascript, need to learn a little
  • Not as easy to debug

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.

share|improve this answer

I think both Node.js and EvenMachine will get the job done, I would really suggest you to go with the language you are more familiar with or even better the one you like working with :)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.