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 NodeJS Server Side JavaScript Environment

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 NodeJS Server Side JavaScript Environment (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

"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 

Recently uploaded (20)

"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 

NodeJS Server Side JavaScript Environment

  • 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!