node
DESCRIPTION
TRANSCRIPT
![Page 1: Node](https://reader035.vdocuments.us/reader035/viewer/2022081804/5495db88b47959744d8b4ea8/html5/thumbnails/1.jpg)
How to node!
![Page 2: Node](https://reader035.vdocuments.us/reader035/viewer/2022081804/5495db88b47959744d8b4ea8/html5/thumbnails/2.jpg)
•Javascript on the server
•Asynchronous and non-blocking code
•Event driven
•Scalable real-time applications
What is Node?
![Page 3: Node](https://reader035.vdocuments.us/reader035/viewer/2022081804/5495db88b47959744d8b4ea8/html5/thumbnails/3.jpg)
•NGINX
•Tornado
•Thin
Existing solutions
![Page 4: Node](https://reader035.vdocuments.us/reader035/viewer/2022081804/5495db88b47959744d8b4ea8/html5/thumbnails/4.jpg)
Node v/s PHP
PHPPHP NodeNode
"Hello World" Simple html file
3177.27 5579.30
"File Read" Textfile of 100KB
20.31 47.21
"Read Remote File"Read a remote page and deliver
3.21 6.43
![Page 5: Node](https://reader035.vdocuments.us/reader035/viewer/2022081804/5495db88b47959744d8b4ea8/html5/thumbnails/5.jpg)
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
![Page 6: Node](https://reader035.vdocuments.us/reader035/viewer/2022081804/5495db88b47959744d8b4ea8/html5/thumbnails/6.jpg)
Node v/s the rest
Same environement. Variables : Fixed concurrency of 300, size of response
![Page 7: Node](https://reader035.vdocuments.us/reader035/viewer/2022081804/5495db88b47959744d8b4ea8/html5/thumbnails/7.jpg)
•Runs on Google’s V8 Engine
Javascript on the Server?
![Page 8: Node](https://reader035.vdocuments.us/reader035/viewer/2022081804/5495db88b47959744d8b4ea8/html5/thumbnails/8.jpg)
•Request is processed sequentially
•Queued requests
Conventional Server
![Page 9: Node](https://reader035.vdocuments.us/reader035/viewer/2022081804/5495db88b47959744d8b4ea8/html5/thumbnails/9.jpg)
•Concurrent execution
•Non-blocking code
•Scalable
Asynchronous Server
![Page 10: Node](https://reader035.vdocuments.us/reader035/viewer/2022081804/5495db88b47959744d8b4ea8/html5/thumbnails/10.jpg)
How does Node do it all?
![Page 11: Node](https://reader035.vdocuments.us/reader035/viewer/2022081804/5495db88b47959744d8b4ea8/html5/thumbnails/11.jpg)
Node Server//Node
http = require('http');
http.createServer(function(request, response){
response.writeHead(200);
response.write('Hello World');
response.end();
}).listen(8000);
![Page 12: Node](https://reader035.vdocuments.us/reader035/viewer/2022081804/5495db88b47959744d8b4ea8/html5/thumbnails/12.jpg)
Event Driven//JSwindow.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);
![Page 13: Node](https://reader035.vdocuments.us/reader035/viewer/2022081804/5495db88b47959744d8b4ea8/html5/thumbnails/13.jpg)
Examples
![Page 14: Node](https://reader035.vdocuments.us/reader035/viewer/2022081804/5495db88b47959744d8b4ea8/html5/thumbnails/14.jpg)
Real World Real Time App
•Hummingbird
•Wheat
•Multi player games
•Real time push notifications
![Page 15: Node](https://reader035.vdocuments.us/reader035/viewer/2022081804/5495db88b47959744d8b4ea8/html5/thumbnails/15.jpg)
Extend Node
•NPM
•Socket.io
•Now
•Express.js
![Page 16: Node](https://reader035.vdocuments.us/reader035/viewer/2022081804/5495db88b47959744d8b4ea8/html5/thumbnails/16.jpg)
•Why to Node?
•When to Node?
•When not to?
How to Node?
![Page 17: Node](https://reader035.vdocuments.us/reader035/viewer/2022081804/5495db88b47959744d8b4ea8/html5/thumbnails/17.jpg)
•http://nodejs.org
•http://npmjs.org
•http://howtonode.org
•http://github.com/joyent/node
Resources
![Page 18: Node](https://reader035.vdocuments.us/reader035/viewer/2022081804/5495db88b47959744d8b4ea8/html5/thumbnails/18.jpg)
Thanks
Arjun Raj
(http://athousandnodes.com | @athousandnodes)