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

PDF
Node.js for beginner
PPTX
How to Build a Multi-DC Cassandra Cluster in AWS with OpsCenter LCM
PPTX
Seastar at Linux Foundation Collaboration Summit
PDF
AWS Fargate in practice. How to run containers without managing EC2 instances
PDF
Seastar @ NYCC++UG
PPTX
Going Serverless
PDF
OpenShift.io on Gluster
PDF
OTechs Cloud Computing Training Course
Node.js for beginner
How to Build a Multi-DC Cassandra Cluster in AWS with OpsCenter LCM
Seastar at Linux Foundation Collaboration Summit
AWS Fargate in practice. How to run containers without managing EC2 instances
Seastar @ NYCC++UG
Going Serverless
OpenShift.io on Gluster
OTechs Cloud Computing Training Course

What's hot (20)

PPTX
Node.js, for architects - OpenSlava 2013
PDF
Understanding the Single Thread Event Loop
PDF
Ndb cluster 80_requirements
PPTX
Azure management portal
PDF
Ndb cluster 80_tpc_h
PPTX
Webinar Back to Basics 3 - Introduzione ai Replica Set
PDF
10 Devops-Friendly Database Must-Haves - Dor Laor, ScyllaDB - DevOpsDays Tel ...
PDF
Mashing the data
PPTX
A docker love story
PPTX
JSR107 Come, Code, Cache, Compute!
PDF
An Introduction to Priam
PPTX
Meteor presentation
PPTX
Creating Highly Available MongoDB Microservices with Docker Containers and Ku...
PDF
Ndb cluster 80_oci_dbt2
PPTX
Deploy meteor in production
PDF
Painless ruby deployment on shelly cloud
PDF
Unleashing k8 s to reduce complexities of an entire middleware platform
PPTX
Understanding and tuning WiredTiger, the new high performance database engine...
PPTX
Migrating legacy e-commerce application to MS Azure
PPT
A Brief Introduce to WSGI
Node.js, for architects - OpenSlava 2013
Understanding the Single Thread Event Loop
Ndb cluster 80_requirements
Azure management portal
Ndb cluster 80_tpc_h
Webinar Back to Basics 3 - Introduzione ai Replica Set
10 Devops-Friendly Database Must-Haves - Dor Laor, ScyllaDB - DevOpsDays Tel ...
Mashing the data
A docker love story
JSR107 Come, Code, Cache, Compute!
An Introduction to Priam
Meteor presentation
Creating Highly Available MongoDB Microservices with Docker Containers and Ku...
Ndb cluster 80_oci_dbt2
Deploy meteor in production
Painless ruby deployment on shelly cloud
Unleashing k8 s to reduce complexities of an entire middleware platform
Understanding and tuning WiredTiger, the new high performance database engine...
Migrating legacy e-commerce application to MS Azure
A Brief Introduce to WSGI
Ad

Viewers also liked (10)

PPTX
Life Quotes
PDF
Pioneers Certificate PS L3
PPTX
Пропозиція щодо співробітництва в межах зарплатного проекту
PPTX
2004 1
PDF
Programma completo dell'estate polignanese 2015
PDF
Nivas_IBM_TGMC
PDF
Bharat_Bhama-Resume
PDF
Hướng dẫn sử dụng Zalo Official Account
PPTX
FinTech Belgium - Regulation and FinTech innovation 16 02 2016
PPTX
Galanz_Case Entire analysis
Life Quotes
Pioneers Certificate PS L3
Пропозиція щодо співробітництва в межах зарплатного проекту
2004 1
Programma completo dell'estate polignanese 2015
Nivas_IBM_TGMC
Bharat_Bhama-Resume
Hướng dẫn sử dụng Zalo Official Account
FinTech Belgium - Regulation and FinTech innovation 16 02 2016
Galanz_Case Entire analysis
Ad

Similar to Introduction to NodeJS (20)

PDF
NodeJS ecosystem
PDF
Node js internal
PPT
Node js
PPTX
Building Applications With the MEAN Stack
PPTX
Beginners Node.js
PPT
Scalability using Node.js
PDF
Top 30 Node.js interview questions
PPTX
Nodejs intro
PPTX
Server Side Web Development Unit 1 of Nodejs.pptx
PPTX
NodeJS guide for beginners
PDF
Introduction to Node JS.pdf
PPTX
PDF
Node.js Enterprise Middleware
PPTX
Introduction to Node.JS
PDF
Beginning MEAN Stack
ODP
Introduce about Nodejs - duyetdev.com
PDF
Tech io nodejs_20130531_v0.6
PPTX
Introduction to Node.js
PDF
NodeJS : Communication and Round Robin Way
PPTX
Node.js meetup at Palo Alto Networks Tel Aviv
NodeJS ecosystem
Node js internal
Node js
Building Applications With the MEAN Stack
Beginners Node.js
Scalability using Node.js
Top 30 Node.js interview questions
Nodejs intro
Server Side Web Development Unit 1 of Nodejs.pptx
NodeJS guide for beginners
Introduction to Node JS.pdf
Node.js Enterprise Middleware
Introduction to Node.JS
Beginning MEAN Stack
Introduce about Nodejs - duyetdev.com
Tech io nodejs_20130531_v0.6
Introduction to Node.js
NodeJS : Communication and Round Robin Way
Node.js meetup at Palo Alto Networks Tel Aviv

Recently uploaded (20)

PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
Digital Strategies for Manufacturing Companies
PPTX
Odoo POS Development Services by CandidRoot Solutions
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
history of c programming in notes for students .pptx
PDF
System and Network Administration Chapter 2
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
How to Migrate SBCGlobal Email to Yahoo Easily
Operating system designcfffgfgggggggvggggggggg
How Creative Agencies Leverage Project Management Software.pdf
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Digital Strategies for Manufacturing Companies
Odoo POS Development Services by CandidRoot Solutions
CHAPTER 2 - PM Management and IT Context
How to Choose the Right IT Partner for Your Business in Malaysia
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Design an Analysis of Algorithms I-SECS-1021-03
Softaken Excel to vCard Converter Software.pdf
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Reimagine Home Health with the Power of Agentic AI​
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Odoo Companies in India – Driving Business Transformation.pdf
history of c programming in notes for students .pptx
System and Network Administration Chapter 2
Upgrade and Innovation Strategies for SAP ERP Customers

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 = 'amol@gmail.com'; $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