SlideShare a Scribd company logo
Introduction To Node.JS
Introduction to NodeJS
What is Node JS ?
According to Node Website (nodejs.org) :
Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine. Node.js
uses an event-driven, non-blocking I/O model that makes it lightweight and
efficient.
As an asynchronous event driven JavaScript runtime, Node is designed to build
scalable network applications
Important Points from Definition:
1)Based On Javascript
2)Non-blocking I/O
3)Event-Driven
4)Uses Chrome’s V8 Engine
5)Perfect for Build Scalable application
6)LightWeight
What is Blocking?
Code that is slow.
<?php
$x = 3;
$email = 'amol@gmail.com';
$result = mysqli_query($con,"SELECT * from users WHERE email = $email");
$otherCode = someCalculation();
?>
Introduction to NodeJS
Handling More Requests in synchronous languages
Create more threads/processes to handle load.
1:1 ratio between thread and request.
1 2 3 4 n
Memory/Thread = 4 MB
RAM = 8 GB
Concurrent request = 2000
Callstack
function createUser(userName) {
createUserId(userName);
};
function createUserId(userName) {
saveUser(userName);
};
function saveUser(user) {
Save in Memory & return;
};
createUser('Mohit'); createUser(Mohit’)
createUserId(‘Mohit’)
saveUser(‘Mohit’)
Some Other Tasks();
Some Other Tasks’s callstack
function createUser(userName) {
createUserId(userName);
};
function createUserId(userName) {
saveUser(userName);
};
function saveUser(user) {
mysql.save('user',function(){
log('Mohit is Permanantly
Saved');
});
};
createUser('Mohit');
Some Other Tasks()
createUser('Mohit')
createUserId('Mohit')
saveUser('Mohit')
Some Other Tasks()
Log('Mohit Is Permanantly Saved');
Node’s Non Blocking Model
function saveUser(user) {
mysql.save('user',function(){
});
}
For Asynchronous Tasks Node uses callbacks and eventLoop.
mysql.save('user', callback);
Server Related
Modules
Server Related
Modules
Synchronous Task
Synchronous Task
Asynchronous Task
mysql.save(user,callback);
Synchronous Task
Asynchronous Task
Thread Pool
Libuv
Event QueueEvent Loop
Event 1 Event 2
Event 1 Callback
Event 2 Callback
Advantages of Event Loop Model
1)It keep main thread free from time consuming tasks.
2)Main thread is able to accept large number of requests.
3)Less memory usage and thread context switching
When to use Node.Js
1)To build Data Intensive(Query Intensive) Application.
2)Highly Scalable Application
When not to use Node.Js
Applications/tasks which blocks main thread.
Example :
1)Image Processing
2)Long running mathematical computation
for(let i = 0; i < 1000000;i++) {
someTask();
}
Scaling
Using all CPU Cores
10k rpm 10k rpm 10k rpm 10k rpm
Load Balancer
Vertical Scaling
Increase machine capacity by increase processing power and memory.
80k rpm
Load Balancer
Horizontal Scaling
Increase Application throughput by increasing number of servers.
Load Balancer Load Balancer Load Balancer
Load Balancer
Scale Cube
NPM
NPM is package manager for NodeJS.
NPM Motto : do one thing and do it well
Http Server
const http = require('http');
const hostname = '127.0.0.1';
const port = 3000;
const server = http.createServer(function(req, res) {
setTimeout(function() {
res.end('Hello Worldn');
}, 100);
});
server.listen(port, hostname, function() {
console.log(`Server running at http://${hostname}:${port}/`);
});
Companies Using Node in production
Thank You
Uttam Aaseri
uttam.aaseri@canvass.in

More Related Content

What's hot (20)

PPTX
Node.js, for architects - OpenSlava 2013
Oscar Renalias
 
PDF
Understanding the Single Thread Event Loop
TorontoNodeJS
 
PDF
Ndb cluster 80_requirements
mikaelronstrom
 
PPTX
Azure management portal
Amal Dev
 
PDF
Ndb cluster 80_tpc_h
mikaelronstrom
 
PPTX
Webinar Back to Basics 3 - Introduzione ai Replica Set
MongoDB
 
PDF
10 Devops-Friendly Database Must-Haves - Dor Laor, ScyllaDB - DevOpsDays Tel ...
DevOpsDays Tel Aviv
 
PDF
Mashing the data
Felix Crisan
 
PPTX
A docker love story
Brian de Heus
 
PPTX
JSR107 Come, Code, Cache, Compute!
Payara
 
PDF
An Introduction to Priam
Jason Brown
 
PPTX
Meteor presentation
Andy Bute
 
PPTX
Creating Highly Available MongoDB Microservices with Docker Containers and Ku...
MongoDB
 
PDF
Ndb cluster 80_oci_dbt2
mikaelronstrom
 
PPTX
Deploy meteor in production
Miro Radenovic
 
PDF
Painless ruby deployment on shelly cloud
Giedrius Rimkus
 
PDF
Unleashing k8 s to reduce complexities of an entire middleware platform
Lakmal Warusawithana
 
PPTX
Understanding and tuning WiredTiger, the new high performance database engine...
Ontico
 
PPTX
Migrating legacy e-commerce application to MS Azure
Eugene Shuvaev
 
PPT
A Brief Introduce to WSGI
Mingli Yuan
 
Node.js, for architects - OpenSlava 2013
Oscar Renalias
 
Understanding the Single Thread Event Loop
TorontoNodeJS
 
Ndb cluster 80_requirements
mikaelronstrom
 
Azure management portal
Amal Dev
 
Ndb cluster 80_tpc_h
mikaelronstrom
 
Webinar Back to Basics 3 - Introduzione ai Replica Set
MongoDB
 
10 Devops-Friendly Database Must-Haves - Dor Laor, ScyllaDB - DevOpsDays Tel ...
DevOpsDays Tel Aviv
 
Mashing the data
Felix Crisan
 
A docker love story
Brian de Heus
 
JSR107 Come, Code, Cache, Compute!
Payara
 
An Introduction to Priam
Jason Brown
 
Meteor presentation
Andy Bute
 
Creating Highly Available MongoDB Microservices with Docker Containers and Ku...
MongoDB
 
Ndb cluster 80_oci_dbt2
mikaelronstrom
 
Deploy meteor in production
Miro Radenovic
 
Painless ruby deployment on shelly cloud
Giedrius Rimkus
 
Unleashing k8 s to reduce complexities of an entire middleware platform
Lakmal Warusawithana
 
Understanding and tuning WiredTiger, the new high performance database engine...
Ontico
 
Migrating legacy e-commerce application to MS Azure
Eugene Shuvaev
 
A Brief Introduce to WSGI
Mingli Yuan
 

Viewers also liked (10)

PPTX
Life Quotes
Randomchick
 
PDF
Pioneers Certificate PS L3
Issa Natsheh
 
PPTX
Пропозиція щодо співробітництва в межах зарплатного проекту
Prominvestbank
 
PPTX
2004 1
awramlara
 
PDF
Programma completo dell'estate polignanese 2015
Nicola Teofilo
 
PDF
Nivas_IBM_TGMC
Nivas Kilari Ravi
 
PDF
Bharat_Bhama-Resume
Bharat Bhushan Bhama , CSM
 
PDF
Hướng dẫn sử dụng Zalo Official Account
Duy Nguyen
 
PPTX
FinTech Belgium - Regulation and FinTech innovation 16 02 2016
Catherine Houssa
 
PPTX
Galanz_Case Entire analysis
Slide Mba
 
Life Quotes
Randomchick
 
Pioneers Certificate PS L3
Issa Natsheh
 
Пропозиція щодо співробітництва в межах зарплатного проекту
Prominvestbank
 
2004 1
awramlara
 
Programma completo dell'estate polignanese 2015
Nicola Teofilo
 
Nivas_IBM_TGMC
Nivas Kilari Ravi
 
Bharat_Bhama-Resume
Bharat Bhushan Bhama , CSM
 
Hướng dẫn sử dụng Zalo Official Account
Duy Nguyen
 
FinTech Belgium - Regulation and FinTech innovation 16 02 2016
Catherine Houssa
 
Galanz_Case Entire analysis
Slide Mba
 
Ad

Similar to Introduction to NodeJS (20)

PPTX
Node
Ankit Chawla
 
PPTX
An overview of node.js
valuebound
 
PPTX
Proposal
Constantine Priemski
 
PPT
18_Node.js.ppt
KhalilSalhi7
 
PPTX
Beginners Node.js
Khaled Mosharraf
 
PPTX
NodeJS - Server Side JS
Ganesh Kondal
 
PPT
18_Node.js.ppt
MaulikShah516542
 
PPTX
Kalp Corporate Node JS Perfect Guide
Kalp Corporate
 
PDF
Introduction to Node JS.pdf
Bareen Shaikh
 
PPTX
Nodejs
Vinod Kumar Marupu
 
ODP
Introduce about Nodejs - duyetdev.com
Van-Duyet Le
 
PPT
Node
Manav Prasad
 
PPTX
Introduction to Node.js
Vikash Singh
 
PPTX
What is Node.js
mohamed hadrich
 
PPTX
Introduction to Node.js
NodeXperts
 
PPT
Introduction to node.js aka NodeJS
JITENDRA KUMAR PATEL
 
PDF
Node js internal
Chinh Ngo Nguyen
 
PPT
Introducción y comandos en NodeJS slodte
lmcsenatic
 
PPTX
Node js
Fatih Şimşek
 
PPT
Node.js
Neethu Dasan
 
An overview of node.js
valuebound
 
18_Node.js.ppt
KhalilSalhi7
 
Beginners Node.js
Khaled Mosharraf
 
NodeJS - Server Side JS
Ganesh Kondal
 
18_Node.js.ppt
MaulikShah516542
 
Kalp Corporate Node JS Perfect Guide
Kalp Corporate
 
Introduction to Node JS.pdf
Bareen Shaikh
 
Introduce about Nodejs - duyetdev.com
Van-Duyet Le
 
Introduction to Node.js
Vikash Singh
 
What is Node.js
mohamed hadrich
 
Introduction to Node.js
NodeXperts
 
Introduction to node.js aka NodeJS
JITENDRA KUMAR PATEL
 
Node js internal
Chinh Ngo Nguyen
 
Introducción y comandos en NodeJS slodte
lmcsenatic
 
Node.js
Neethu Dasan
 
Ad

Recently uploaded (20)

PPTX
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
PDF
Why Are More Businesses Choosing Partners Over Freelancers for Salesforce.pdf
Cymetrix Software
 
PDF
Protecting the Digital World Cyber Securit
dnthakkar16
 
PPT
Brief History of Python by Learning Python in three hours
adanechb21
 
PDF
SAP GUI Installation Guide for macOS (iOS) | Connect to SAP Systems on Mac
SAP Vista, an A L T Z E N Company
 
PDF
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
 
PPTX
Presentation about Database and Database Administrator
abhishekchauhan86963
 
PPT
Why Reliable Server Maintenance Service in New York is Crucial for Your Business
Sam Vohra
 
PPTX
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
 
PDF
Using licensed Data Loss Prevention (DLP) as a strategic proactive data secur...
Q-Advise
 
PPTX
TRAVEL APIs | WHITE LABEL TRAVEL API | TOP TRAVEL APIs
philipnathen82
 
PDF
Generating Union types w/ Static Analysis
K. Matthew Dupree
 
PDF
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
ESUG
 
PDF
AWS_Agentic_AI_in_Indian_BFSI_A_Strategic_Blueprint_for_Customer.pdf
siddharthnetsavvies
 
PDF
Infrastructure planning and resilience - Keith Hastings.pptx.pdf
Safe Software
 
PPT
Activate_Methodology_Summary presentatio
annapureddyn
 
PDF
Summary Of Odoo 18.1 to 18.4 : The Way For Odoo 19
CandidRoot Solutions Private Limited
 
PPTX
Presentation about variables and constant.pptx
kr2589474
 
PDF
Supabase Meetup: Build in a weekend, scale to millions
Carlo Gilmar Padilla Santana
 
PDF
Salesforce Implementation Services Provider.pdf
VALiNTRY360
 
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
Why Are More Businesses Choosing Partners Over Freelancers for Salesforce.pdf
Cymetrix Software
 
Protecting the Digital World Cyber Securit
dnthakkar16
 
Brief History of Python by Learning Python in three hours
adanechb21
 
SAP GUI Installation Guide for macOS (iOS) | Connect to SAP Systems on Mac
SAP Vista, an A L T Z E N Company
 
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
 
Presentation about Database and Database Administrator
abhishekchauhan86963
 
Why Reliable Server Maintenance Service in New York is Crucial for Your Business
Sam Vohra
 
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
 
Using licensed Data Loss Prevention (DLP) as a strategic proactive data secur...
Q-Advise
 
TRAVEL APIs | WHITE LABEL TRAVEL API | TOP TRAVEL APIs
philipnathen82
 
Generating Union types w/ Static Analysis
K. Matthew Dupree
 
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
ESUG
 
AWS_Agentic_AI_in_Indian_BFSI_A_Strategic_Blueprint_for_Customer.pdf
siddharthnetsavvies
 
Infrastructure planning and resilience - Keith Hastings.pptx.pdf
Safe Software
 
Activate_Methodology_Summary presentatio
annapureddyn
 
Summary Of Odoo 18.1 to 18.4 : The Way For Odoo 19
CandidRoot Solutions Private Limited
 
Presentation about variables and constant.pptx
kr2589474
 
Supabase Meetup: Build in a weekend, scale to millions
Carlo Gilmar Padilla Santana
 
Salesforce Implementation Services Provider.pdf
VALiNTRY360
 

Introduction to NodeJS

  • 3. What is Node JS ? According to Node Website (nodejs.org) : Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. As an asynchronous event driven JavaScript runtime, Node is designed to build scalable network applications
  • 4. Important Points from Definition: 1)Based On Javascript 2)Non-blocking I/O 3)Event-Driven 4)Uses Chrome’s V8 Engine 5)Perfect for Build Scalable application 6)LightWeight
  • 5. What is Blocking? Code that is slow. <?php $x = 3; $email = '[email protected]'; $result = mysqli_query($con,"SELECT * from users WHERE email = $email"); $otherCode = someCalculation(); ?>
  • 7. Handling More Requests in synchronous languages Create more threads/processes to handle load. 1:1 ratio between thread and request. 1 2 3 4 n Memory/Thread = 4 MB RAM = 8 GB Concurrent request = 2000
  • 8. Callstack function createUser(userName) { createUserId(userName); }; function createUserId(userName) { saveUser(userName); }; function saveUser(user) { Save in Memory & return; }; createUser('Mohit'); createUser(Mohit’) createUserId(‘Mohit’) saveUser(‘Mohit’) Some Other Tasks(); Some Other Tasks’s callstack
  • 9. function createUser(userName) { createUserId(userName); }; function createUserId(userName) { saveUser(userName); }; function saveUser(user) { mysql.save('user',function(){ log('Mohit is Permanantly Saved'); }); }; createUser('Mohit'); Some Other Tasks() createUser('Mohit') createUserId('Mohit') saveUser('Mohit') Some Other Tasks() Log('Mohit Is Permanantly Saved');
  • 10. Node’s Non Blocking Model function saveUser(user) { mysql.save('user',function(){ }); } For Asynchronous Tasks Node uses callbacks and eventLoop. mysql.save('user', callback);
  • 12. Synchronous Task Synchronous Task Asynchronous Task mysql.save(user,callback); Synchronous Task Asynchronous Task Thread Pool Libuv Event QueueEvent Loop Event 1 Event 2 Event 1 Callback Event 2 Callback
  • 13. Advantages of Event Loop Model 1)It keep main thread free from time consuming tasks. 2)Main thread is able to accept large number of requests. 3)Less memory usage and thread context switching
  • 14. When to use Node.Js 1)To build Data Intensive(Query Intensive) Application. 2)Highly Scalable Application
  • 15. When not to use Node.Js Applications/tasks which blocks main thread. Example : 1)Image Processing 2)Long running mathematical computation for(let i = 0; i < 1000000;i++) { someTask(); }
  • 16. Scaling Using all CPU Cores 10k rpm 10k rpm 10k rpm 10k rpm Load Balancer
  • 17. Vertical Scaling Increase machine capacity by increase processing power and memory. 80k rpm Load Balancer
  • 18. Horizontal Scaling Increase Application throughput by increasing number of servers. Load Balancer Load Balancer Load Balancer Load Balancer
  • 20. NPM NPM is package manager for NodeJS. NPM Motto : do one thing and do it well
  • 21. Http Server const http = require('http'); const hostname = '127.0.0.1'; const port = 3000; const server = http.createServer(function(req, res) { setTimeout(function() { res.end('Hello Worldn'); }, 100); }); server.listen(port, hostname, function() { console.log(`Server running at http://${hostname}:${port}/`); });
  • 22. Companies Using Node in production