Danilo Sousadsgoncalves@sp.r7.comNode.js
Introduction"Nodes goal is to provide an easy way to buildscalable network programs."Ryan Dahl●Server-side Javascript●Buil...
I/O needs to be donedifferently.
I/O Costs●L1: 3 cycles●L2: 14 cycles●RAM: 250 cycles●DISK: 41,000,000 cycles●NETWORK: 240,000,000 cycleshttp://nodejs.org/...
Traditional wayvar db = require(db);row = db.query( SELECT id, name FROM aaa);row2 = db.query(SELECT id, name WHERE id = +...
I/O Costs●L1: 3 cycles●L2: 14 cycles●RAM: 250 cycles●DISK: 41,000,000 cycles●NETWORK: 240,000,000 cycleshttp://nodejs.org/...
Nodes first attemptvar db = require(db);db.query( SELECT id, name FROM table, function(row){db.query(SELECT .... WHERE id ...
Better wayvar db = require(db);frunction get(cb){db.query(SELECT id, name FROM table, row1);}function row1(row, cb){db.que...
speed
speedvar http = require(’http’);var b = new Buffer(1024*1024);http.createServer(function(req, res){res.writeHead(200);res....
speed100 concurrent clients1 megabyte responsereq/secnode ~800nginx ~700thin 85mongrel 4(bigger is better)by Ryan Dahl
Questions?
Upcoming SlideShare
Loading in …5
×

Node.js

406 views

Published on

  • Be the first to comment

  • Be the first to like this

Node.js

  1. 1. Danilo Sousadsgoncalves@sp.r7.comNode.js
  2. 2. Introduction"Nodes goal is to provide an easy way to buildscalable network programs."Ryan Dahl●Server-side Javascript●Built on Google’s V8●CommonJS module system●Evented, non-blocking I/O. Similar to EventMachine orTwisted.
  3. 3. I/O needs to be donedifferently.
  4. 4. I/O Costs●L1: 3 cycles●L2: 14 cycles●RAM: 250 cycles●DISK: 41,000,000 cycles●NETWORK: 240,000,000 cycleshttp://nodejs.org/jsconf.pdf
  5. 5. Traditional wayvar db = require(db);row = db.query( SELECT id, name FROM aaa);row2 = db.query(SELECT id, name WHERE id = +row.id );// do your stuff hereconsole.log( row2.name );
  6. 6. I/O Costs●L1: 3 cycles●L2: 14 cycles●RAM: 250 cycles●DISK: 41,000,000 cycles●NETWORK: 240,000,000 cycleshttp://nodejs.org/jsconf.pdf
  7. 7. Nodes first attemptvar db = require(db);db.query( SELECT id, name FROM table, function(row){db.query(SELECT .... WHERE id = +row.id, function(row2){// do your stuff hereconsole.log( row2.name );});});
  8. 8. Better wayvar db = require(db);frunction get(cb){db.query(SELECT id, name FROM table, row1);}function row1(row, cb){db.query(SELECT .... WHERE id = + row.id, function(row){cb( row );});}get(function(row){console.log( row.name );});
  9. 9. speed
  10. 10. speedvar http = require(’http’);var b = new Buffer(1024*1024);http.createServer(function(req, res){res.writeHead(200);res.end(b);}).listen(8000);by Ryan Dahl
  11. 11. speed100 concurrent clients1 megabyte responsereq/secnode ~800nginx ~700thin 85mongrel 4(bigger is better)by Ryan Dahl
  12. 12. Questions?

×