You’ve seen cool node.js demos, buzz on twitter about it and now even one of your friends mentions it.  What is node.js?  Why on Earth would you want to run javascript on the server side?  Why do we need another language for server side programming?  I’ll try my best to answer these questions and provide a simple explanation of node.

What Node.js Is:

  • A web/application/socket server built off of Google Chrome’s notoriously fast V8 javascript engine.
  • Rather than spawning new threads for each new connection to your server like thread based webservers (Apache for example) that dominate the server stack today, node utilizes a single thread with an event loop to manage requests.
  • Node.js makes vast use of asynchronous i/o whether it be to disk, database, network or waiting for file uploads.

Why Using Javascript In Particular Google Chrome’s V8 Engine Makes Sense:

  • Javascript is a well known language to many developers
  • It is already set up with an easy to use event loop architecture due to its anonymous functions, closures and callbacks.
  • Its fast.  V8 has three pillars to performance: fast property access, dynamic machine code generation and efficient garbage collection that allow it to execute javascript at very near native speeds.

Why Using This Architecture Is Advantageous:

  • Thread switching carries a cost that makes thread driven web servers slower as the number of concurrent requets grows.
  • With the growing number of rich internet applications using ajax and websockets frequent, smaller requests have become more commonplace.  (Think google instant)  This increases the number of concurrent requests.
  • The non-blocking i/o gives is main advantage here, because the web server’s responsiveness is much less so coupled to the number of simultaneous database queries.  (esp. if you’re using some sort of NoSQL system like redis, memcached or MongoDB)
  • Its not only a web server.  Its also just as easy to set up a socket server using node.

Thats pretty much why its a cool project, and gaining momentum fast.  If you’d like to hear more about some of node’s justifications check out this video by its creator Ryan Dahl: 

A link to the main node project site (top image links there too):

http://www.nodejs.org/

In the next few posts we’ll set the stage as to some of node’s history/community and how to get started.