What & why node.js

Node.js, what is it??? Node.js is a software system designed for making brilliant webservers that can host scalable (rich) internet applications in an event-driven way.

Why event driven (versus thread-based)?

What do we mean with this? The webservers we are used to know, like Apache, IIS are thread-based. As soon as you start communicating with them, you have your own private communication line with the webserver. Nobody else is allowed to use that one, until you are completely done. In comparison, node.js & nginx (Thanks Bradley Wright for pointing this out), as soon as it received your request, doesn’t wait for the request to be completed and send back. It stacks the request on a queue, and goes to the next request, from someone else. So a user requesting something, is an event. Node.js stacks them up, and each them when it finished a request, will reestablish contact with the client again.

If this doesn’t make sense to you, please read Dan York’s blogpost.

Scalable?

An open connection between a client and a node.js application, only requires minimum memory / cpu (server-side). A test by Matt Ranney from Voxer actually made clear that they sooner ran out of ports, than cpu or memory. This means that when having about a bit less than 65535 open connections, the node.js server still continued working, without remarquable lag.

Rich internet applications?

These websites, are applications that formerly only used to be a program. Like a Calendar, Word, … . Thy process your input, and update what you did without the pages refreshes. They are connected with other users. And what you see could actually change, when somebody else changes something, somewhere else on the internet.

Javascript V8?

To create something in Node.Js, you have to write a program. That program, can contain the code for the actual web server implementation. The code, has to be written in Javascript. Node.js use Javascript, because it can use V8, the (open source) engine from Google, to run/handle it.

When should you use it?

When should you not use it?

  • You do not want to learn something new.
  • Websites.
  • Very complex thingss.
  • If it is not deployable.
  • If it has to be real stable (still very young platform)
When should you use it?

  • If you have many connections.
  • If it has to be very quick, like desktop software.
  • If your client code already is in Javascript.
  • If you use push apis.
  • Transcoding.
  • Real Time data

This table is a summary from an openminds slideshow.

What is next?

I am going to write a tutorial about setting a Node.js server up, about making a hello world application and something more complicated.

Thanks & comments!

Thanks for reading. If there are any mistakes in this articles, please comment! If you have anything to add to this, please contribute!

Sources:

  • http://code.danyork.com/2011/01/25/node-js-doctors-offices-and-fast-food-restaurants-understanding-event-driven-programming/
  • http://www.sdtimes.com/content/article.aspx?ArticleID=35668&page=1
  • http://www.slideshare.net/frank_be/nodejs-waarom-en-hoe (dutch presentation)
  • http://www.theregister.co.uk/2011/03/01/the_rise_and_rise_of_node_dot_js/

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>