24

Please tell me if:

  • Node.js will make our site faster!
  • Node.js will consume fewer server resources, we can save money!
  • Node.js will make us more productive!
  • Node.js means we can share client and server side JavaScript code.

To clarify, we're rewriting a frontend server, which will talk to our existing Ruby on Rails application as an API. Meanwhile, we'll refactor our Ruby on Rails application into services.

More details on the existing architecture:

  • Memcached for HTML partials caching
  • Redis for session, and some structured data caching
  • MySQL single master, multiple slaves
    • There's one large table that accepts a lot of writes (imagine a poll)
    • Otherwise mostly reads.
  • MongoDB for some metadata
  • Ruby on Rails 3.0
  • nginx and Unicorn
user88487
  • 257

2 Answers2

22

Most of the questions you ask are not answerable without context, and are more or less moot given management has already made the choice for you... unless you are asking 'should I quit and find a new job in the face of all this change?'

If your going to tough it out I recommend you read this this post on the topic: How To Survive a Ground-Up Rewrite Without Losing Your Sanity.

I recently started down the path of rewriting a bit of server logic in node.js. The main reason was it is currently written in .NET and we are wanting to migrate away from MS environments down the track.

My experiences so far have been positive, you will have an initial learning curve with all the non-blocking-ness of it but once you get past that it's actually quite fun to code in.. I know, FUN!

It does have a dark side though, every man and his dog who has done some front end development with JavaScript - and that would be every front end developer I hope - gets a little excited when you mention that node.js is 'server side javascript' however that does not mean front end developers will have the experience required to write good server side apps.

For one thing you have consider is that a fatal error will bring down the whole app due to it's non threaded nature, so the stakes are a little higher and you have to explicitly check and catch everything.

For those who have done both front and back - and enjoy both - not having to switch mental contexts from front end to back end languages is a real bonus that I think will ultimately boost productivity in our team down the track.

gnat
  • 20,543
  • 29
  • 115
  • 306
dave.zap
  • 569
8

Well, I don't think that rewriting the application was a good idea unless it was performing poorly. To answer your questions:

  1. Node.js is not magic. Your application has huge amount of users, so there is no way to be certain that it will make it faster.

  2. Well, yes, Node.js does in fact consume fewer server resources. So not only can you save money on resources, but you can also do more with the existing ones. This is mostly because of single-threaded nature of Node.js. There is no overhead of additional threads.

  3. Again Node.js is not magic. Having said that, there might be some truth in that. Node.js has a very active community that has created hundreds of modules for every possible task. So it is quite probable that most of the work has been done for you. You just need to fit the pieces together.

  4. Theoretically, yes. Since Node.js is JavaScript, you can share code between the client and server. But I don't know exactly what it is that will be shared. I have not written any piece of code that was reusable on a client. Things that we do on the server usually has nothing to do with the client. More important to me is the lack of context switch. I find it easier to code on both client and server in a single language.

Since Node.js is single-threaded, unless explicitly configured to do so, it can't take advantage of multiple CPUs.

Take a look at the comments too. They provide some good insight into the workings of Node.js.

Akshat Jiwan Sharma
  • 444
  • 2
  • 5
  • 10