7

I'm in the process of building a complex web app that must work a lot with real-time data and showing that data to the user.

Given that I'm more used to Rails, I'm wondering if there's a big advantage of dumping rails and use node.js to build the app or if there's a way I can have the real-time advantages of Node.js in Rails.

Better would be to be able to use Node.js and Rails. Is that a possibility?

Thanks

donald
  • 23,587
  • 42
  • 142
  • 223

3 Answers3

6

Better would be to be able to use Node.js and Rails. Is that a possibility?

IMHO combining the best of both worlds is a very good idea since you can use your existing experience to build "standard" MVC parts of your web application and use node.js for specific real-time based elements. This can not only widen your skill set but you can also learn new techniques on how to solve various problems with appropriate tools.

yojimbo87
  • 65,684
  • 25
  • 123
  • 131
  • @yojimbo87, that's exactly what I intend to do. However, I'm not totally sure how I can communicate between the Rails app and the Node.js app. What do you suggest? Thanks. – donald Apr 04 '11 at 14:17
  • @donald: This is a good topic for a new question, can you please post a new question regarding communication between these two technologies, so it can be easier to find for others seeking the same knowledge. Thanks. – yojimbo87 Apr 04 '11 at 14:26
  • sure! here it is: http://stackoverflow.com/questions/5539990/communicate-between-a-rails-app-and-a-node-js-app – donald Apr 04 '11 at 14:29
  • Combining the best of both worlds will just slow everything down. I recommend you just sit down and learn to use node. – Raynos Apr 04 '11 at 15:21
  • @Raynos: "will just slow everything down" - that's just argumentative and proofless. – yojimbo87 Apr 04 '11 at 15:33
  • @yojimbo87 If you want a real time application then having data going through an extra data channel between RoR and node will defeat the point. I can see the value of using RoR to server HTML/CSS/JS and using node to set up a websocket and having both talk to seperate databases. But to keep it real time you should design it so it doesn't require communication between rails & node. – Raynos Apr 04 '11 at 15:37
  • @Raynos: You can distribute the load between RoR based MVC functionality and node.js based real-time stuff which can make both systems more predictable, manageable and you can still take advantage of what specific framework offer since it's not like node.js is far more superior in everything what RoR does or vice versa. – yojimbo87 Apr 04 '11 at 15:59
  • @yojimbo87 I see your point. Yes it can be advantageous to use both. I still heavily recommend you use RoR and node for two separate services and do not have them inter-communicate. Tbh you can combine RoR with EventMachine and completely drop node if you wanted to. I personally don't like half measures and feel that communication between the two would defeat the point. – Raynos Apr 04 '11 at 16:08
2

You should read this : Ruby on rails and Node.js

The answers of Shripad K and Andy Atkinson are greats !

Community
  • 1
  • 1
Sandro Munda
  • 39,921
  • 24
  • 98
  • 123
1

Node.js has a lot of advantages, but you do have to know what you're doing to take advantage of it's power. That usually takes some time. The primary bonus against rails is that Node.js is more lightweight than Rails (which is saying a lot, IMO), and supports higher concurrency.

Though I feel I should side note at this point that a lot of real-time data retrieval doesn't necessarily mean you need high concurrency. It means that you need to make sure your middle tier and data access tier are very speedy, and that you can handle the throughput. By definition, Node.js covers the first one. Though either way you're talking in low milliseconds for response times.

If you want to get in to the JavaScript event-driven world, I'd certainly recommend trying it out. But for something that's not just a 'test it out' project (for your first attempt), I don't know how good of an idea it is.

Either way, best of luck!

Christopher WJ Rueber
  • 2,141
  • 15
  • 22
  • My main problem of using node.js for "everything" is that I don't want to lose the advantages and simplicity of Rails for creating a CRUD app. I mostly want to use Node for processing and communicating with the Rails app. Maybe using Redis? – donald Apr 04 '11 at 14:19
  • Can't say I disagree with you, particularly in the case of your current familiarity with Rails. Seems like it's only adding an extra layer between the end user and the application then, in that case. The biggest advantage for using something like Node.js and a NoSQL store (I can't speak to Redis as I've not worked directly with it) are that they are event driven models, whereas Rails is not. I don't think that stops Rails from being fast (far from it), it just tends to need more 'scale out' ability than some Node.js servers do. – Christopher WJ Rueber Apr 04 '11 at 14:27
  • 1
    As a side note, it may be worth taking a look at Sinatra, rather than switching languages entirely (which often creates maintainability problems). Sinatra coupled with the right server is pretty blazin' fast. May offer you the same type of really lightweight middleware that you are looking to get out of Node.js, without the disadvantage of being in a new language. – Christopher WJ Rueber Apr 04 '11 at 14:31