How to node!
What is Node?
• Javascript on the server
• Asynchronous and non-blocking code
• Event driven
• Scalable real-time applications
Existing solutions

• NGINX
• Tornado
• Thin
Node v/s PHP

                                           PHP           Node
"Hello World"
                                 3177.27         5579.30
Simple html file



"File Read"                      20.31           47.21
Textfile of 100KB



"Read Remote File"               3.21            6.43
Read a remote page and deliver
Node v/s the rest




Tested under Ubuntu using a Intel Core 2 Duo,2.53 GHz, 4 GB memory, Approximately 100 byte response for each
Node v/s the rest




Same environement. Variables : Fixed concurrency of 300, size of response
Javascript on the Server?



• Runs on Google’s V8 Engine
Conventional Server
• Request is processed sequentially
• Queued requests
Asynchronous Server
• Concurrent execution
• Non-blocking code
• Scalable
How does Node do it all?
Node Server
//Node
http = require('http');
http.createServer(function(request, response){
   response.writeHead(200);
  response.write('Hello World');
   response.end();
}).listen(8000);
Event Driven
   //JS
   window.onload = function(){
       document.body.innerHTML = 'Hello World';
   };


//Node
http = require('http');
http.createServer(function(request, response){
     response.writeHead(200);
     response.write('Hello World');
     response.end();
}).listen(8000);
Examples
Real World Real Time App

• Hummingbird
• Wheat
• Multi player games
• Real time push notifications
Extend Node
• NPM
• Socket.io
• Now
• Express.js
How to Node?

• Why to Node?
• When to Node?
• When not to?
Resources

• http://nodejs.org
• http://npmjs.org
• http://howtonode.org
• http://github.com/joyent/node
Thanks


               Arjun Raj
(http://athousandnodes.com | @athousandnodes)

Node