SlideShare a Scribd company logo
1 of 26
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
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 

More Related Content

What's hot

From MEAN to the MERN Stack
From MEAN to the MERN StackFrom MEAN to the MERN Stack
From MEAN to the MERN StackTroy 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.jsGary Yeh
 
Node.js Web Apps @ ebay scale
Node.js Web Apps @ ebay scaleNode.js Web Apps @ ebay scale
Node.js Web Apps @ ebay scaleDmytro Semenov
 
A brief intro to nodejs
A brief intro to nodejsA brief intro to nodejs
A brief intro to nodejsJay 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 OnlineAndre Weissflog
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsRob O'Doherty
 
Node.js tutoria for beginner
Node.js tutoria for beginnerNode.js tutoria for beginner
Node.js tutoria for beginnerManinder Singh
 
NodeJS guide for beginners
NodeJS guide for beginnersNodeJS guide for beginners
NodeJS guide for beginnersEnoch 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 / HTML5David Voyles
 
Understanding the Single Thread Event Loop
Understanding the Single Thread Event LoopUnderstanding the Single Thread Event Loop
Understanding the Single Thread Event LoopTorontoNodeJS
 
MEAN Stack WeNode Barcelona Workshop
MEAN Stack WeNode Barcelona WorkshopMEAN Stack WeNode Barcelona Workshop
MEAN Stack WeNode Barcelona WorkshopValeri 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, DhakaNurul 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
 

What's hot (20)

Node.js for beginner
Node.js for beginnerNode.js for beginner
Node.js for beginner
 
From MEAN to the MERN Stack
From MEAN to the MERN StackFrom MEAN to the MERN Stack
From MEAN to the MERN Stack
 
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
 
Node.js Web Apps @ ebay scale
Node.js Web Apps @ ebay scaleNode.js Web Apps @ ebay scale
Node.js Web Apps @ ebay scale
 
A brief intro to nodejs
A brief intro to nodejsA brief intro to nodejs
A brief intro to nodejs
 
Node js internal
Node js internalNode js internal
Node js internal
 
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
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
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
 
Introduction to Node js
Introduction to Node jsIntroduction to Node js
Introduction to Node js
 
Node.js tutoria for beginner
Node.js tutoria for beginnerNode.js tutoria for beginner
Node.js tutoria for beginner
 
Nodejs basics
Nodejs basicsNodejs basics
Nodejs basics
 
NodeJS guide for beginners
NodeJS guide for beginnersNodeJS guide for beginners
NodeJS guide for beginners
 
Node.js Chapter1
Node.js Chapter1Node.js Chapter1
Node.js Chapter1
 
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
 
Nodejs
NodejsNodejs
Nodejs
 
Understanding the Single Thread Event Loop
Understanding the Single Thread Event LoopUnderstanding the Single Thread Event Loop
Understanding the Single Thread Event Loop
 
MEAN Stack WeNode Barcelona Workshop
MEAN Stack WeNode Barcelona WorkshopMEAN Stack WeNode Barcelona Workshop
MEAN Stack WeNode Barcelona Workshop
 
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
 
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!
 

Similar to Beginners Node.js

Kalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect GuideKalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect GuideKalp Corporate
 
Introduction to node.js aka NodeJS
Introduction to node.js aka NodeJSIntroduction to node.js aka NodeJS
Introduction to node.js aka NodeJSJITENDRA KUMAR PATEL
 
Introduction to Node JS.pdf
Introduction to Node JS.pdfIntroduction to Node JS.pdf
Introduction to Node JS.pdfBareen 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 AvivRon 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 scriptGhulamHussain799241
 
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 jsHabilelabs
 
An introduction to Node.js
An introduction to Node.jsAn introduction to Node.js
An introduction to Node.jsKasey McCurdy
 
Building Applications With the MEAN Stack
Building Applications With the MEAN StackBuilding Applications With the MEAN Stack
Building Applications With the MEAN StackNir Noy
 

Similar to Beginners Node.js (20)

Nodejs
NodejsNodejs
Nodejs
 
20120306 dublin js
20120306 dublin js20120306 dublin js
20120306 dublin js
 
Kalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect GuideKalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect Guide
 
Introduction to node.js aka NodeJS
Introduction to node.js aka NodeJSIntroduction to node.js aka NodeJS
Introduction to node.js aka NodeJS
 
Introduction to Node JS.pdf
Introduction to Node JS.pdfIntroduction to Node JS.pdf
Introduction to Node JS.pdf
 
Real time web
Real time webReal time web
Real time web
 
Node js
Node jsNode js
Node js
 
Nodejs
NodejsNodejs
Nodejs
 
"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)
 
Proposal
ProposalProposal
Proposal
 
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
 
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
 
20120802 timisoara
20120802 timisoara20120802 timisoara
20120802 timisoara
 
What is Mean Stack Development ?
What is Mean Stack Development ?What is Mean Stack Development ?
What is Mean Stack Development ?
 
Top 10 frameworks of node js
Top 10 frameworks of node jsTop 10 frameworks of node js
Top 10 frameworks of node js
 
18_Node.js.ppt
18_Node.js.ppt18_Node.js.ppt
18_Node.js.ppt
 
An introduction to Node.js
An introduction to Node.jsAn introduction to Node.js
An introduction to Node.js
 
Building Applications With the MEAN Stack
Building Applications With the MEAN StackBuilding Applications With the MEAN Stack
Building Applications With the MEAN Stack
 
02 Node introduction
02 Node introduction02 Node introduction
02 Node introduction
 
18_Node.js.ppt
18_Node.js.ppt18_Node.js.ppt
18_Node.js.ppt
 

More from 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 qualityKhaled Mosharraf
 
Data quality management Basic
Data quality management BasicData quality management Basic
Data quality management BasicKhaled Mosharraf
 
Introduction to anonymity network tor
Introduction to anonymity network torIntroduction to anonymity network tor
Introduction to anonymity network torKhaled Mosharraf
 

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,
 
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...
 
Open ssl heart bleed weakness.
Open ssl heart bleed weakness.Open ssl heart bleed weakness.
Open ssl heart bleed weakness.
 
Six sigma
Six sigmaSix sigma
Six sigma
 
Foundation of data quality
Foundation of data qualityFoundation of data quality
Foundation of data quality
 
Data quality management Basic
Data quality management BasicData quality management Basic
Data quality management Basic
 
Introduction to anonymity network tor
Introduction to anonymity network torIntroduction to anonymity network tor
Introduction to anonymity network tor
 

Recently uploaded

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024SynarionITSolutions
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Principled Technologies
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 

Recently uploaded (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 

Beginners Node.js

  • 1. 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
  • 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
  • 3.
  • 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!