Node.js is a platform built on Chrome’s JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.

In the “hello world” web server example below, many client connections can be handled concurrently. Node tells the operating system that it should be notified when a new connection is made, and then it goes to sleep. If someone new connects, then it executes the callback. Each connection is only a small heap allocation.

var http = require('http');
http.createServer(function (req, res)
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(1337, '');
console.log('Server running at');

To run the server, put the code into a file example.js and execute it with the node program:

% node example.js
Server running at

The approach used by Node is in contrast to today’s more common concurrency model where OS threads are employed. Thread-based networking is relatively inefficient and very difficult to use. Node will show much better memory efficiency under high-loads. Users of Node are free from worries of dead-locking the process—there are no locks. Almost no function in Node directly performs I/O, so the process never blocks. Because nothing blocks, less-than-expert programmers are able to develop fast systems.

Here is an example of a simple TCP server which listens on port 1337 and echoes whatever you send it:

var net = require('net');
var server = net.createServer(function (socket) 
 socket.write('Echo server\r\n');
server.listen(1337, '');

Use telnet to test this one

telnet localhost 1337

More information at