Chief Architect James Duncan Discusses Node.js Architecture and Performance
1. Node
James A. Duncan
Chief Architect
james@joyent.com
Friday, March 4, 2011
2. James A. Duncan
Chief Architect @ Joyent
Spend a lot of my time thinking about
how things should join together and
why they shouldnʼt.
Grew up in Hawkesbury, Ontario
Live in the mountains to the north of
Montreal in Quebec, Canada.
Formerly lived in London & was a CIO
of a subsidiary of Canon Europe.
Open Source guy for 15 years.
Gardener, skier, and technologist.
2
Friday, March 4, 2011
39. the node.js project
• Evented server-side javascript
• All IO is non-blocking
• Good at handling lots of different IO at the same time
• Achieves this by making all IO non-blocking
• Primary author, and benevolent dictator for life is Ryan Dahl
• Owned by us (Joyent), but MIT/BSD licensed
• seems to be pretty popular, which is making us happy
• running our http://no.de service - lets you get started using node quickly
• running on HPʼs webOS as the underlying service mechanism (replaced Java)
39
Friday, March 4, 2011
40. a pleasing example
var http = require("http");
var net = require("net");
var c = 0;
http.createServer( function( req, res ) {
c++;
res.writeHead(200);
res.end("Hello World");
}).listen(8000);
net.createServer( function( socket ) {
socket.write("connections: " + c);
socket.end();
}).listen(8001);
40
Friday, March 4, 2011
41. speed is obviously important
• Benchmark:
• nginx v0.7.65
• node v0.1.91
• tornado v0.2 (python 2.6.4)
• thin v1.2.7 (ruby 1.9.1-p376)
• Linux 2.53, using Intel Core 2 Duo & 4GB RAM
• Standard hello world, with a 100 byte response
41
Friday, March 4, 2011