Contact Us


Posted on 24/9/09 by Felix Geisendörfer

What happens if you take an insanely fast JavaScript engine and build an asynchronous I/O library around it? You get node.js, an up and coming project that brings you bloat-free server-side JavaScript.

This enables you to write any kind of "backend" service with just a few lines of JavaScript. But don't take my word for it, here is how a "Hello World" example looks in node.js:

node.http.createServer(function (req, res) {
  setTimeout(function () {
    res.sendHeader(200, {"Content-Type": "text/plain"});
    res.sendBody("Hello World");
  }, 2000);
puts("Server running at");

This code creates a new http server and tells it to listen on port 8000. Whenever a request comes in, the closure function passed to createServer is fired. In this example we are waiting 2 seconds before sending a "Hello World" response back to the client.

However, during those 2 seconds the server will continue to accept new connections. That gives you a very scalable hello world server. Talking about performance: Ryan (the awesome guy behind node.js) has done some initial benchmarks which show how fast of a beast we are talking about here. To me the most notable aspect is the extremely low response times you can achieve with node.js (pretty much 0-1ms).

Here is another chart from a req/sec benchmark among various server-side JS libs:

Now you may think this is all very nice and stuff, but what do you actually need it for? Well, it depends. There are a few people writing web frameworks for node.js, but at this point it would be rather adventurous to build a full blown web application on top of node. However, node has incredible potential if you want to develop chat applications, check out this one for example. We are using node.js to run the backend for which we'll share more details about in the future. One could also easily write his own key-value store in node.js - let's say you'd like to have something like Memcached but with a REST interface.

Trying out node.js requires you to have a Linux/Unix machine but it's pretty much as simple as downloading the code and running:

make install

The documentation is pretty excellent and there are lots of friendly people on the mailing list to help if you have any problems.

To me the most exciting thing about node.js is its incredible potential to reunite. You can have long debates about using Python, Ruby, PHP, Java, ASP or Perl for a web project, but nobody will debate that JavaScript is *the* language of the web. Now imagine the smartest people from all those communities creating code in a single language that works on your browser as well as your server ...

I'd love to hear your thoughts on node.js and any questions you might have. Just leave comment!

-- Felix Geisendörfer aka the_undefined


You can skip to the end and add a comment.

Mohamed Karnichi said on Sep 28, 2009:


Awesome! Can we use Node in production environment? If so, is node.exec Helper secure enough for (for example) use it to make some image file manipulation (crop, rotate) with external program like imagemagick.

Thank you for this post !!

Felix Geisendörfer said on Sep 28, 2009:

Mohamed Karnichi: We use it for exactly that and it's working great. Security is largely up to you when it comes to executing command line tools on your server. So far pretty much all recent version of node have been pretty stable, but it's still developing as a plattform so expect to update your code every once and a while. I'd be glad to help you guys if you need more information about node, just use the contact form to get in touch!

Mohamed Karnichi said on Sep 28, 2009:

Thank you for the answer. we'll try it soon.


Eelco Wiersma said on Oct 01, 2009:

Good stuff! I'm going to play around with this.

Btw pretty nifty concept, good work guys :)

This post is too old. We do not allow comments here anymore in order to fight spam. If you have real feedback or questions for the post, please contact us.