Menu

Sunday, February 16, 2014

Is NodeJS the best solution for your project

Ever since all the commotion around NodeJS started, I was wondering, if javascript is really good for backend development. So I started looking up various subjects regarding NodeJS, like how to configure a production server, benchmarks and others. After doing some reading I was able to form an opinion.


1. JavaScript is event driven.

Although it would be really good to have an asynchronous and event driven application in the backend, the web is stateless. Most web servers use technologies like CGI and Fast CGI, which enable them to execute scripts. While you will be able to configure node to run as a cgi script, you will also be defeating the purpose of using JavaScript in the backend. So to be able to run a node application properly, you will have to setup a node http server that will serve all the requests.

2. Node is single threaded

This part is really interesting. Node is single threaded but asynchronous, and the thing is that if your node application does not do a lot of CPU intensive operations, it can actually handle more requests than the Apache server. One downside is that you would almost every time have to use a balancer to distribute the load across several node servers.

3. Building realtime apps

Node is really good for developing applications that transfer realtime data to the users. Realtime applications are easily monitored by using some third party modules like nodetime, node-uptime, log.io and many others. 

4. Using only one language

NodeJS uses the same engine as google chrome, the V8, and when you are building a web app you will only need to use one language - JavaScript.

Conclusion

Although you could build an event driver realtime app by using Ruby or Python, it would've taken you a lot of time and effort to do so, instead it is way better to use NodeJS, which has event driven asynchronous structure and gives you most of the functionality that you need. But if you are building a large scale web application that needs to handle a lot of concurrent connections, maybe it's better to stick with a threaded system. Anyway it all depends on the technical requirements of the application that you are building. If you want a more detailed explanation of how NodeJS works, read this great article by Tomislav Capan: Why The Hell Would I Use Node.js? A Case-by-Case Introduction

No comments:

Post a Comment