Node.JS Deep Dive training deck by Prasoon Kumar. The presentation introduces Node.JS as a server-side JavaScript framework built on Google's V8 engine that uses a non-blocking and event-driven architecture. It discusses companies using Node.JS like Google, Microsoft, Yahoo and Facebook and how Node.JS handles requests in an event loop as opposed to blocking threads. The presentation also covers installing Node.JS, the Node package ecosystem with NPM, and an API tour of core Node.JS modules for processes, file systems, networking and more.
1 of 22
More Related Content
Node.js introduction
1. Node.JS Deep Dive
Training Deck By
Prasoon Kumar
Senior Technical Architect
Just Dial
Presentation Material
1 18th August,2012
2. What is node?
Server-side JavaScript framework
Written using Google V8 engine
Uses CommonJS module system
Has the ECMASCript5 features
Non-blocking from ground up
Servers are normally thread based but Node.JS is
Event based. Node. JS serves each request in an
Evented loop that can able to handle
simultaneous requests.
3. Who is using it?
Sponsored by
Google
Microsoft (native support in Azure)
Yahoo
eBay
Facebook
LinkedIn
Many, many smaller companies
4. Threads VS Event-driven
Threads Asynchronous Event-driven
Lock application / request with only one thread, which
listener-workers threads repeatedly fetches an event
Using incoming-request model Using queue and then processes
it
multithreaded server might block manually saves state and then
the request which might involve goes on to process the next
multiple events event
Using context switching no contention and no context
switches
Using multithreading Using asynchronous I/O facilities
environments where listener and (callbacks, not poll/select or
workers threads are used O_NONBLOCK) environments
frequently to take an incoming-
request lock
8. Non-blocking IO
The philosophy behind node is that system interactions should be non
blocking.
Instead of this
var fs = require('fs'); // Import the 'fs' module
var data = fs.readFileSync(__dirname + '/example.file','utf8');
console.log(data); // print it!
Use this
var fs = require('fs'); // Import the 'fs' module
// Read the file asynchronously
fs.readFile(__dirname + '/example.file', 'utf8', function (err, data) {
if (err) {
return console.log(err);
}
console.log(data); // print it! });