SlideShare a Scribd company logo
Server side JavaScript environment
Khaled Mosharraf, M.Sc
Fh Kiel Germany
mosharrafkhaled@gmx.de
A.K.M Bahalul Haque, M.Sc
M.Sc Fh Kiel Germany
pallob.nstu@gmail.com
What is NodeJS?
 Complete software platform for scalable server-side &
networking applications
 Bundled with JavaScript Interpreter
 JavaScript runtime environment running Google Chrome’s V8
engine
 Runs over command line
 Never blocks, not even for I/O
 Uses the CommonJS framework
Making it a little closer to a real OO language
Beginners Node.js
Why is it so cool......
• Node JS is fast, in theory
• Low maintenance (small impact on resources)
• Programs must not stress the CPU
• Programming is not THAT easy
• API are well documented
• The Node JS standard library can be EXTENDED
by the use of modules
• the number of available modules is HUGE
• optimised (low resources)
• runs everywhere
Overall Structure
Two Main Components are --
• Main Core, written in C & C++
• Modules, such as Libuv library and V8 runtime
engine, also written
in C++
Background-Achitecture
• libev(event loop)
• libeio(non-block thread pool)
• V8(Javascript engine)
What can NodeJS be used for…..
• Http,
• networking,
• Websockets
• Network servers (HTTP, Proxies, messaging)
• API backends
• Real time applications
• Streaming data
“One page” web sites
• Command line tools
• Bots
---but also it is an invaluable tool for
developers
Browsers
• Every browser has its own VM
• Firefox? Spidermonkey
• Internet Explorer? Chakra
• Chrome? V8
• Safari? JavaScriptCore
• Opera? Carakan
• Also Rhino, stand alone
• Completely event driven (asynchronous, non-
blocking)
When to use Node.js?
• Node.js is good for creating streaming based
real-time services, web chat applications,
static file servers etc.
• If you need high level concurrency and not
worried about CPU-cycles.
• If you are great at writing JavaScript code
because then you can use the same language
at both the places: server-side and client-side.
When to not use Node.js
• When you are doing heavy and CPU intensive calculations on server
side, because event-loops are CPU hungry.
• Node.js API is still in beta, it keeps on changing a lot from one
revision to another and there is a very little backward compatibility.
Most of the packages are also unstable. Therefore is not yet
production ready.
• Node.js is a no match for enterprise level application frameworks
like Spring(java), Django(python), Symfony(php) etc. Applications
written on such platforms are meant to be highly user interactive
and involve complex business logic.
• Read further on disadvantages of Node.js on Quora:
http://www.quora.com/What-are-the-disadvantages-of-using-
Node-js
Features
 Non-blocking I/O
 Event Driven
 CommonJS
How it works.......
Async
Event Loop Example
• Request for “index.html” comes in
• Stack unwinds and ev_loop goes to sleep
• File loads from disk and is sent to the client
What is the “Node Standard Library”?
• A powerful HTTP(S) library (client and server
in no time)
• DNS name resolution
• Crypto
• Access to the file system
• URL manipulation
• ZLIB
• UDP datagrams
Event-loops
• Event-loops are the core of event-driven programming, almost all the UI programs
use event-loops to track the user event, for example: Clicks, Ajax Requests etc.
Client
Event loop
(main thread)
C++
Threadpool
(worker
threads)
Clients send HTTP requests
to Node.js server
An Event-loop is woken up by OS,
passes request and response objects
to the thread-pool
Long-running jobs run
on worker threads
Response is sent
back to main thread
via callback
Event loop returns
result to client
Node.js benchmarks
Taken from:
http://nodejs.org/jsconf2010.pdf
The benchmark shows the response
time in milli-secs for 4 evented
servers.
Taken from:
http://code.google.com/p/node-js-vs-apache-
php-benchmark/wiki/Tests
A benchmark between Apache+PHP
and node.js, shows the response
time for 1000 concurrent
connections making 10,000 requests
each, for 5 tests.
Example (HTTP Server & TCP Server)
• Following code creates an HTTP Server and prints ‘Hello World’ on the
browser:
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello Worldn'); }).listen(5000, "127.0.0.1");
• Here is an example of a simple TCP server which listens on port 6000 and
echoes whatever you send it:
var net = require('net');
net.createServer(function (socket) {
socket.write("Echo serverrn");
socket.pipe(socket); }).listen(6000, "127.0.0.1");
Lets connect to a DB (MongoDB)
• Install mongojs using npm, a mongoDB driver for
Node.js
npm install mongojs
• Code to retrieve all the documents from a
collection:
var db = require("mongojs")
.connect("localhost:27017/test", ['test']);
db.test.find({}, function(err, posts) {
if( err || !posts) console.log("No posts found");
else posts.forEach( function(post) {
console.log(post);
});
});
Node.js Ecosystem
• Node.js heavily relies on modules, in previous
examples require keyword loaded the http & net
modules.
• Creating a module is easy, just put your JavaScript code
in a separate js file and include it in your code by using
keyword require, like:
var modulex = require(‘./modulex’);
• Libraries in Node.js are called packages and they can be
installed by typing
npm install “package_name”; //package should be available in npm
registry @ nmpjs.org
• NPM (Node Package Manager) comes bundled with
Node.js installation.
Critical Analysis......
Benefits
• Because of single threaded nonb locking scheme nodejs can
support up to one million concurrent nodes
• Can be used to implement entire havascript based web
applications
• Request are acknowledged because of asynchronous nature
• Native JSON handling
• Easy RESTful services
• Speedy native bindings in C
• Realtime nature i.e possible to process fiels while they are
being uploaded
Critical Analysis......
Best for..
• REST + JSON Api
• Quick Prototyping
• Chat applications
• Ideal for computing and orchastration tasks
• For fast growing applications
Limitations....
• Tightly coupled Node & V8 engines
• Low fault tolerance
• Exception handling
• Some lackings in code quality
Who is using Node.js in production?
• Yahoo! : iPad App Livestand uses Yahoo! Manhattan
framework which is based on Node.js.
• LinkedIn : LinkedIn uses a combination of Node.js and
MongoDB for its mobile platform. iOS and Android apps are
based on it.
• eBay : Uses Node.js along with ql.io to help application
developers in improving eBay’s end user experience.
• Dow Jones : The WSJ Social front-end is written completely
in Node.js, using Express.js, and many other modules.
• Complete list can be found at:
https://github.com/joyent/node/wiki/Projects,-
Applications,-and-Companies-Using-Node
Conclusion
 Still in beta
 Non-blocking nature takes some getting used
to
 Interesting API
 Can almost remake Dash!
??
Any
Question 
Ad

More Related Content

What's hot (20)

Node.js for beginner
Node.js for beginnerNode.js for beginner
Node.js for beginner
Sarunyhot Suwannachoti
 
From MEAN to the MERN Stack
From MEAN to the MERN StackFrom MEAN to the MERN Stack
From MEAN to the MERN Stack
Troy Miles
 
Basic Understanding and Implement of Node.js
Basic Understanding and Implement of Node.jsBasic Understanding and Implement of Node.js
Basic Understanding and Implement of Node.js
Gary Yeh
 
Node.js Web Apps @ ebay scale
Node.js Web Apps @ ebay scaleNode.js Web Apps @ ebay scale
Node.js Web Apps @ ebay scale
Dmytro Semenov
 
A brief intro to nodejs
A brief intro to nodejsA brief intro to nodejs
A brief intro to nodejs
Jay Liu
 
Node js internal
Node js internalNode js internal
Node js internal
Chinh Ngo Nguyen
 
Data Management and Streaming Strategies in Drakensang Online
Data Management and Streaming Strategies in Drakensang OnlineData Management and Streaming Strategies in Drakensang Online
Data Management and Streaming Strategies in Drakensang Online
Andre Weissflog
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
Rob O'Doherty
 
8 Most Effective Node.js Tools for Developers
8 Most Effective Node.js Tools for Developers8 Most Effective Node.js Tools for Developers
8 Most Effective Node.js Tools for Developers
iMOBDEV Technologies Pvt. Ltd.
 
Introduction to Node js
Introduction to Node jsIntroduction to Node js
Introduction to Node js
Pragnesh Vaghela
 
Node.js tutoria for beginner
Node.js tutoria for beginnerNode.js tutoria for beginner
Node.js tutoria for beginner
Maninder Singh
 
Nodejs basics
Nodejs basicsNodejs basics
Nodejs basics
monikadeshmane
 
NodeJS guide for beginners
NodeJS guide for beginnersNodeJS guide for beginners
NodeJS guide for beginners
Enoch Joshua
 
Node.js Chapter1
Node.js Chapter1Node.js Chapter1
Node.js Chapter1
Talentica Software
 
Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5
Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5
Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5
David Voyles
 
Nodejs
NodejsNodejs
Nodejs
Prem Sanil
 
Understanding the Single Thread Event Loop
Understanding the Single Thread Event LoopUnderstanding the Single Thread Event Loop
Understanding the Single Thread Event Loop
TorontoNodeJS
 
MEAN Stack WeNode Barcelona Workshop
MEAN Stack WeNode Barcelona WorkshopMEAN Stack WeNode Barcelona Workshop
MEAN Stack WeNode Barcelona Workshop
Valeri Karpov
 
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, DhakaJavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
Nurul Ferdous
 
Run your Dockerized ASP.NET application on Windows and Linux!
Run your Dockerized ASP.NET application on Windows and Linux!Run your Dockerized ASP.NET application on Windows and Linux!
Run your Dockerized ASP.NET application on Windows and Linux!
Alex Thissen
 
From MEAN to the MERN Stack
From MEAN to the MERN StackFrom MEAN to the MERN Stack
From MEAN to the MERN Stack
Troy Miles
 
Basic Understanding and Implement of Node.js
Basic Understanding and Implement of Node.jsBasic Understanding and Implement of Node.js
Basic Understanding and Implement of Node.js
Gary Yeh
 
Node.js Web Apps @ ebay scale
Node.js Web Apps @ ebay scaleNode.js Web Apps @ ebay scale
Node.js Web Apps @ ebay scale
Dmytro Semenov
 
A brief intro to nodejs
A brief intro to nodejsA brief intro to nodejs
A brief intro to nodejs
Jay Liu
 
Data Management and Streaming Strategies in Drakensang Online
Data Management and Streaming Strategies in Drakensang OnlineData Management and Streaming Strategies in Drakensang Online
Data Management and Streaming Strategies in Drakensang Online
Andre Weissflog
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
Rob O'Doherty
 
Node.js tutoria for beginner
Node.js tutoria for beginnerNode.js tutoria for beginner
Node.js tutoria for beginner
Maninder Singh
 
NodeJS guide for beginners
NodeJS guide for beginnersNodeJS guide for beginners
NodeJS guide for beginners
Enoch Joshua
 
Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5
Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5
Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5
David Voyles
 
Understanding the Single Thread Event Loop
Understanding the Single Thread Event LoopUnderstanding the Single Thread Event Loop
Understanding the Single Thread Event Loop
TorontoNodeJS
 
MEAN Stack WeNode Barcelona Workshop
MEAN Stack WeNode Barcelona WorkshopMEAN Stack WeNode Barcelona Workshop
MEAN Stack WeNode Barcelona Workshop
Valeri Karpov
 
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, DhakaJavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
Nurul Ferdous
 
Run your Dockerized ASP.NET application on Windows and Linux!
Run your Dockerized ASP.NET application on Windows and Linux!Run your Dockerized ASP.NET application on Windows and Linux!
Run your Dockerized ASP.NET application on Windows and Linux!
Alex Thissen
 

Similar to Beginners Node.js (20)

Nodejs
NodejsNodejs
Nodejs
Vinod Kumar Marupu
 
20120306 dublin js
20120306 dublin js20120306 dublin js
20120306 dublin js
Richard Rodger
 
Kalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect GuideKalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect Guide
Kalp Corporate
 
Introduction to node.js aka NodeJS
Introduction to node.js aka NodeJSIntroduction to node.js aka NodeJS
Introduction to node.js aka NodeJS
JITENDRA KUMAR PATEL
 
Introduction to Node JS.pdf
Introduction to Node JS.pdfIntroduction to Node JS.pdf
Introduction to Node JS.pdf
Bareen Shaikh
 
Real time web
Real time webReal time web
Real time web
Medhat Dawoud
 
Node js
Node jsNode js
Node js
Chirag Parmar
 
Nodejs
NodejsNodejs
Nodejs
Bhushan Patil
 
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
Tech in Asia ID
 
Proposal
ProposalProposal
Proposal
Constantine Priemski
 
concept of server-side JavaScript / JS Framework: NODEJS
concept of server-side JavaScript / JS Framework: NODEJSconcept of server-side JavaScript / JS Framework: NODEJS
concept of server-side JavaScript / JS Framework: NODEJS
Kongu Engineering College, Perundurai, Erode
 
Node.js meetup at Palo Alto Networks Tel Aviv
Node.js meetup at Palo Alto Networks Tel AvivNode.js meetup at Palo Alto Networks Tel Aviv
Node.js meetup at Palo Alto Networks Tel Aviv
Ron Perlmuter
 
Difference between Node.js vs Java script
Difference between Node.js vs Java scriptDifference between Node.js vs Java script
Difference between Node.js vs Java script
GhulamHussain799241
 
20120802 timisoara
20120802 timisoara20120802 timisoara
20120802 timisoara
Richard Rodger
 
What is Mean Stack Development ?
What is Mean Stack Development ?What is Mean Stack Development ?
What is Mean Stack Development ?
Balajihope
 
Top 10 frameworks of node js
Top 10 frameworks of node jsTop 10 frameworks of node js
Top 10 frameworks of node js
HabileLabs
 
18_Node.js.ppt
18_Node.js.ppt18_Node.js.ppt
18_Node.js.ppt
MaulikShah516542
 
An introduction to Node.js
An introduction to Node.jsAn introduction to Node.js
An introduction to Node.js
Kasey McCurdy
 
Building Applications With the MEAN Stack
Building Applications With the MEAN StackBuilding Applications With the MEAN Stack
Building Applications With the MEAN Stack
Nir Noy
 
02 Node introduction
02 Node introduction02 Node introduction
02 Node introduction
Ahmed Elbassel
 
Kalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect GuideKalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect Guide
Kalp Corporate
 
Introduction to node.js aka NodeJS
Introduction to node.js aka NodeJSIntroduction to node.js aka NodeJS
Introduction to node.js aka NodeJS
JITENDRA KUMAR PATEL
 
Introduction to Node JS.pdf
Introduction to Node JS.pdfIntroduction to Node JS.pdf
Introduction to Node JS.pdf
Bareen Shaikh
 
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
Tech in Asia ID
 
Node.js meetup at Palo Alto Networks Tel Aviv
Node.js meetup at Palo Alto Networks Tel AvivNode.js meetup at Palo Alto Networks Tel Aviv
Node.js meetup at Palo Alto Networks Tel Aviv
Ron Perlmuter
 
Difference between Node.js vs Java script
Difference between Node.js vs Java scriptDifference between Node.js vs Java script
Difference between Node.js vs Java script
GhulamHussain799241
 
What is Mean Stack Development ?
What is Mean Stack Development ?What is Mean Stack Development ?
What is Mean Stack Development ?
Balajihope
 
Top 10 frameworks of node js
Top 10 frameworks of node jsTop 10 frameworks of node js
Top 10 frameworks of node js
HabileLabs
 
An introduction to Node.js
An introduction to Node.jsAn introduction to Node.js
An introduction to Node.js
Kasey McCurdy
 
Building Applications With the MEAN Stack
Building Applications With the MEAN StackBuilding Applications With the MEAN Stack
Building Applications With the MEAN Stack
Nir Noy
 
Ad

More from Khaled Mosharraf (7)

PCI DSS introduction by khaled mosharraf,
PCI DSS introduction by khaled mosharraf,PCI DSS introduction by khaled mosharraf,
PCI DSS introduction by khaled mosharraf,
Khaled Mosharraf
 
Pixel Bar Charts A New Technique for Visualizing Large Multi-Attribute Data S...
Pixel Bar Charts A New Technique for Visualizing Large Multi-Attribute Data S...Pixel Bar Charts A New Technique for Visualizing Large Multi-Attribute Data S...
Pixel Bar Charts A New Technique for Visualizing Large Multi-Attribute Data S...
Khaled Mosharraf
 
Open ssl heart bleed weakness.
Open ssl heart bleed weakness.Open ssl heart bleed weakness.
Open ssl heart bleed weakness.
Khaled Mosharraf
 
Six sigma
Six sigmaSix sigma
Six sigma
Khaled Mosharraf
 
Foundation of data quality
Foundation of data qualityFoundation of data quality
Foundation of data quality
Khaled Mosharraf
 
Data quality management Basic
Data quality management BasicData quality management Basic
Data quality management Basic
Khaled Mosharraf
 
Introduction to anonymity network tor
Introduction to anonymity network torIntroduction to anonymity network tor
Introduction to anonymity network tor
Khaled Mosharraf
 
PCI DSS introduction by khaled mosharraf,
PCI DSS introduction by khaled mosharraf,PCI DSS introduction by khaled mosharraf,
PCI DSS introduction by khaled mosharraf,
Khaled Mosharraf
 
Pixel Bar Charts A New Technique for Visualizing Large Multi-Attribute Data S...
Pixel Bar Charts A New Technique for Visualizing Large Multi-Attribute Data S...Pixel Bar Charts A New Technique for Visualizing Large Multi-Attribute Data S...
Pixel Bar Charts A New Technique for Visualizing Large Multi-Attribute Data S...
Khaled Mosharraf
 
Open ssl heart bleed weakness.
Open ssl heart bleed weakness.Open ssl heart bleed weakness.
Open ssl heart bleed weakness.
Khaled Mosharraf
 
Foundation of data quality
Foundation of data qualityFoundation of data quality
Foundation of data quality
Khaled Mosharraf
 
Data quality management Basic
Data quality management BasicData quality management Basic
Data quality management Basic
Khaled Mosharraf
 
Introduction to anonymity network tor
Introduction to anonymity network torIntroduction to anonymity network tor
Introduction to anonymity network tor
Khaled Mosharraf
 
Ad

Recently uploaded (20)

Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 

Beginners Node.js

  • 1. Server side JavaScript environment Khaled Mosharraf, M.Sc Fh Kiel Germany [email protected] A.K.M Bahalul Haque, M.Sc M.Sc Fh Kiel Germany [email protected]
  • 2. What is NodeJS?  Complete software platform for scalable server-side & networking applications  Bundled with JavaScript Interpreter  JavaScript runtime environment running Google Chrome’s V8 engine  Runs over command line  Never blocks, not even for I/O  Uses the CommonJS framework Making it a little closer to a real OO language
  • 4. Why is it so cool...... • Node JS is fast, in theory • Low maintenance (small impact on resources) • Programs must not stress the CPU • Programming is not THAT easy • API are well documented • The Node JS standard library can be EXTENDED by the use of modules • the number of available modules is HUGE • optimised (low resources) • runs everywhere
  • 5. Overall Structure Two Main Components are -- • Main Core, written in C & C++ • Modules, such as Libuv library and V8 runtime engine, also written in C++
  • 6. Background-Achitecture • libev(event loop) • libeio(non-block thread pool) • V8(Javascript engine)
  • 7. What can NodeJS be used for….. • Http, • networking, • Websockets • Network servers (HTTP, Proxies, messaging) • API backends • Real time applications • Streaming data “One page” web sites • Command line tools • Bots ---but also it is an invaluable tool for developers
  • 8. Browsers • Every browser has its own VM • Firefox? Spidermonkey • Internet Explorer? Chakra • Chrome? V8 • Safari? JavaScriptCore • Opera? Carakan • Also Rhino, stand alone • Completely event driven (asynchronous, non- blocking)
  • 9. When to use Node.js? • Node.js is good for creating streaming based real-time services, web chat applications, static file servers etc. • If you need high level concurrency and not worried about CPU-cycles. • If you are great at writing JavaScript code because then you can use the same language at both the places: server-side and client-side.
  • 10. When to not use Node.js • When you are doing heavy and CPU intensive calculations on server side, because event-loops are CPU hungry. • Node.js API is still in beta, it keeps on changing a lot from one revision to another and there is a very little backward compatibility. Most of the packages are also unstable. Therefore is not yet production ready. • Node.js is a no match for enterprise level application frameworks like Spring(java), Django(python), Symfony(php) etc. Applications written on such platforms are meant to be highly user interactive and involve complex business logic. • Read further on disadvantages of Node.js on Quora: http://www.quora.com/What-are-the-disadvantages-of-using- Node-js
  • 11. Features  Non-blocking I/O  Event Driven  CommonJS
  • 13. Async
  • 14. Event Loop Example • Request for “index.html” comes in • Stack unwinds and ev_loop goes to sleep • File loads from disk and is sent to the client
  • 15. What is the “Node Standard Library”? • A powerful HTTP(S) library (client and server in no time) • DNS name resolution • Crypto • Access to the file system • URL manipulation • ZLIB • UDP datagrams
  • 16. Event-loops • Event-loops are the core of event-driven programming, almost all the UI programs use event-loops to track the user event, for example: Clicks, Ajax Requests etc. Client Event loop (main thread) C++ Threadpool (worker threads) Clients send HTTP requests to Node.js server An Event-loop is woken up by OS, passes request and response objects to the thread-pool Long-running jobs run on worker threads Response is sent back to main thread via callback Event loop returns result to client
  • 17. Node.js benchmarks Taken from: http://nodejs.org/jsconf2010.pdf The benchmark shows the response time in milli-secs for 4 evented servers. Taken from: http://code.google.com/p/node-js-vs-apache- php-benchmark/wiki/Tests A benchmark between Apache+PHP and node.js, shows the response time for 1000 concurrent connections making 10,000 requests each, for 5 tests.
  • 18. Example (HTTP Server & TCP Server) • Following code creates an HTTP Server and prints ‘Hello World’ on the browser: var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello Worldn'); }).listen(5000, "127.0.0.1"); • Here is an example of a simple TCP server which listens on port 6000 and echoes whatever you send it: var net = require('net'); net.createServer(function (socket) { socket.write("Echo serverrn"); socket.pipe(socket); }).listen(6000, "127.0.0.1");
  • 19. Lets connect to a DB (MongoDB) • Install mongojs using npm, a mongoDB driver for Node.js npm install mongojs • Code to retrieve all the documents from a collection: var db = require("mongojs") .connect("localhost:27017/test", ['test']); db.test.find({}, function(err, posts) { if( err || !posts) console.log("No posts found"); else posts.forEach( function(post) { console.log(post); }); });
  • 20. Node.js Ecosystem • Node.js heavily relies on modules, in previous examples require keyword loaded the http & net modules. • Creating a module is easy, just put your JavaScript code in a separate js file and include it in your code by using keyword require, like: var modulex = require(‘./modulex’); • Libraries in Node.js are called packages and they can be installed by typing npm install “package_name”; //package should be available in npm registry @ nmpjs.org • NPM (Node Package Manager) comes bundled with Node.js installation.
  • 21. Critical Analysis...... Benefits • Because of single threaded nonb locking scheme nodejs can support up to one million concurrent nodes • Can be used to implement entire havascript based web applications • Request are acknowledged because of asynchronous nature • Native JSON handling • Easy RESTful services • Speedy native bindings in C • Realtime nature i.e possible to process fiels while they are being uploaded
  • 22. Critical Analysis...... Best for.. • REST + JSON Api • Quick Prototyping • Chat applications • Ideal for computing and orchastration tasks • For fast growing applications
  • 23. Limitations.... • Tightly coupled Node & V8 engines • Low fault tolerance • Exception handling • Some lackings in code quality
  • 24. Who is using Node.js in production? • Yahoo! : iPad App Livestand uses Yahoo! Manhattan framework which is based on Node.js. • LinkedIn : LinkedIn uses a combination of Node.js and MongoDB for its mobile platform. iOS and Android apps are based on it. • eBay : Uses Node.js along with ql.io to help application developers in improving eBay’s end user experience. • Dow Jones : The WSJ Social front-end is written completely in Node.js, using Express.js, and many other modules. • Complete list can be found at: https://github.com/joyent/node/wiki/Projects,- Applications,-and-Companies-Using-Node
  • 25. Conclusion  Still in beta  Non-blocking nature takes some getting used to  Interesting API  Can almost remake Dash!