SlideShare uma empresa Scribd logo
1 de 18
An Overview of Node.js
N. Kishorekumar
https://www.drupal.org/u/nkishorekumar
https://twitter.com/kishorekumar920
● Introduction
● Some (Confusing) Theory
● Few Examples
● A couple of weird diagrams
● Pics showing unbelievable benchmarks
● Some stuff from Internet
What To Expect Ahead....
● V8 is an open source JavaScript engine developed by Google.
● Node.js runs on V8.
● It was created by Ryan Dahl in 2009.
● Is Open Source. It runs well on Linux systems, can also run on
Windows systems.
● If you have worked on EventMachine (Ruby) or Python’s Twisted
or Perl’s AnyEvent framework then following presentation is
going to be very easy.
Background
● In simple words Node.js is ‘server-side JavaScript’.
● In not-so-simple words Node.js is a high-performance network
applications framework, well optimized for high concurrent
environments.
● It’s a command line tool.
● In ‘Node.js’ , ‘.js’ doesn’t mean that its solely written in JavaScript.
It is 40% JS and 60% C++.
● From the official site:
‘Node's goal is to provide an easy way to build scalable network
programs’ - (from nodejs.org!)
Introduction: Basic
● Node.js uses an event-driven, non-blocking I/O model, which
makes it lightweight. (from nodejs.org!)
● It makes use of event-loops via JavaScript’s callback functionality
to implement the non-blocking I/O.
● Programs for Node.js are written in JavaScript but not in the
same JavaScript we are use to. There is no DOM implementation
provided by Node.js, i.e.
you cannot do this:
var element = document.getElementById(‚elementId‛);
● Everything inside Node.js runs in a single-thread.
Introduction: Advanced (Confusing)
● In an event-driven application, there is generally a main loop
that listens for events, and then triggers a callback function
when one of those events is detected.
Some Theory : Event Driven
● Traditional I/O
var result = db.query(‚select x from table_Y‛);
doSomethingWith(result); //wait for result!
doSomethingWithOutResult(); //execution is blocked!
● Non-traditional, Non-blocking I/O
db.query(‚select x from table_Y”,function (result){
doSomethingWith(result); //wait for result!
});
doSomethingWithOutResult(); //executes without any
Delay!
Some Theory: Non-Blocking I/O
● Install/build Node.js.
(Yes! Windows installer is available!)
● Open your favorite editor and start typing JavaScript.
● When you are done, open cmd/terminal and type this:
‘node YOUR_FILE.js’
● Here is a simple example, which prints ‘hello world’
setTimeout(function(){
console.log('world');},3000);
console.log('hello');
//it prints ‘hello’ first and waits for 3 seconds and then prints
‘world’
Example 1: Getting Started &
Hello World
● You can create an HTTP server and print ‘hello world’ on the
browser in just 4 lines of JavaScript. (Example included)
● You can create a TCP server similar to HTTP server, in just 4 lines of
JavaScript. (Example included)
● You can create a DNS server.
● You can create a Static File Server.
● You can create a Web Chat Application like GTalk in the browser.
● Node.js can also be used for creating online games, collaboration
tools or anything which sends updates to the user in real-time.
What Can You Do With Node.js ?
● 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");
Example 2 & 3 (HTTP Server & TCP
Server)
● 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.
● More can be found at:
○ http://stackoverflow.com/questions/5062614/how-to-
decide-when-to-use-nodejs
When To Use Node.js ?
Install nTwitter module using npm:
Npm install ntwitter
Code:
var twitter = require('ntwitter');
var twit = new twitter({
consumer_key: ‘c_key’,
consumer_secret: ‘c_secret’,
access_token_key: ‘token_key’,
access_token_secret: ‘token_secret’});
twit.stream('statuses/sample', function(stream) {
stream.on('data', function (data) {
console.log(data); });
});
Example 4: Twitter Streaming
Click to add text
Benchmarks
● CPU Heavy jobs : When you are doing heavy and CPU intensive
calculations on server side, because event-loops are CPU hungry.
● CRUD - Node.js would be superfluous for simple HTML or CRUD
applications
● 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:
https://www.quora.com/What-are-the-disadvantages-of-using-
Node-js
When To Not Use Node.js
● 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
Appendix 1: Who Is Using Node.js
In Production?
● Express – to make things simpler e.g. syntax, DB connections.
● Jade – HTML template system
● Socket.IO – to create real-time apps
● Nodemon – to monitor Node.js and push change automatically
● CoffeeScript – for easier JavaScript development
● Find out more about some widely used Node.js modules at:
http://blog.nodejitsu.com/top-node-module-creators
Appendix 2: Some Good Modules
● Watch this video at Youtube:
http://www.youtube.com/watch?v=jo_B4LTHi3I
● Read the free O’reilly Book ‘Up and Running with Node.js’
http://ofps.oreilly.com/titles/9781449398583/
● Visit www.nodejs.org for Info/News about Node.js
● Watch Node.js tutorials @ http://nodetuts.com/
● For Info on MongoDB:
http://www.mongodb.org/display/DOCS/Home
● For anything else Google!
Appendix 3: Resource To Get
Started
Thank you!

Mais conteúdo relacionado

Mais procurados

Basic Concept of Node.js & NPM
Basic Concept of Node.js & NPMBasic Concept of Node.js & NPM
Basic Concept of Node.js & NPMBhargav Anadkat
 
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
 
JavaScript From Hell - CONFidence 2.0 2009
JavaScript From Hell - CONFidence 2.0 2009JavaScript From Hell - CONFidence 2.0 2009
JavaScript From Hell - CONFidence 2.0 2009Mario Heiderich
 
Node.js Course 1 of 2 - Introduction and first steps
Node.js Course 1 of 2 - Introduction and first stepsNode.js Course 1 of 2 - Introduction and first steps
Node.js Course 1 of 2 - Introduction and first stepsManuel Eusebio de Paz Carmona
 
NodeJS - Server Side JS
NodeJS - Server Side JS NodeJS - Server Side JS
NodeJS - Server Side JS Ganesh Kondal
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.jsDinesh U
 
HTML, CSS & Javascript Architecture (extended version) - Jan Kraus
HTML, CSS & Javascript Architecture (extended version) - Jan KrausHTML, CSS & Javascript Architecture (extended version) - Jan Kraus
HTML, CSS & Javascript Architecture (extended version) - Jan KrausWomen in Technology Poland
 
Generic Attack Detection - ph-Neutral 0x7d8
Generic Attack Detection - ph-Neutral 0x7d8Generic Attack Detection - ph-Neutral 0x7d8
Generic Attack Detection - ph-Neutral 0x7d8Mario Heiderich
 
Introduction to Node js
Introduction to Node jsIntroduction to Node js
Introduction to Node jsAkshay Mathur
 

Mais procurados (20)

Nodejs
NodejsNodejs
Nodejs
 
Node.js Basics
Node.js Basics Node.js Basics
Node.js Basics
 
Node
NodeNode
Node
 
Basic Concept of Node.js & NPM
Basic Concept of Node.js & NPMBasic Concept of Node.js & NPM
Basic Concept of Node.js & NPM
 
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
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
 
JavaScript From Hell - CONFidence 2.0 2009
JavaScript From Hell - CONFidence 2.0 2009JavaScript From Hell - CONFidence 2.0 2009
JavaScript From Hell - CONFidence 2.0 2009
 
Node.js an Exectutive View
Node.js an Exectutive ViewNode.js an Exectutive View
Node.js an Exectutive View
 
Node
NodeNode
Node
 
Node.js Course 1 of 2 - Introduction and first steps
Node.js Course 1 of 2 - Introduction and first stepsNode.js Course 1 of 2 - Introduction and first steps
Node.js Course 1 of 2 - Introduction and first steps
 
NodeJS overview
NodeJS overviewNodeJS overview
NodeJS overview
 
NodeJS - Server Side JS
NodeJS - Server Side JS NodeJS - Server Side JS
NodeJS - Server Side JS
 
Node.js Course 2 of 2 - Advanced techniques
Node.js Course 2 of 2 - Advanced techniquesNode.js Course 2 of 2 - Advanced techniques
Node.js Course 2 of 2 - Advanced techniques
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.js
 
Future of NodeJS
Future of NodeJSFuture of NodeJS
Future of NodeJS
 
Node js for beginners
Node js for beginnersNode js for beginners
Node js for beginners
 
HTML, CSS & Javascript Architecture (extended version) - Jan Kraus
HTML, CSS & Javascript Architecture (extended version) - Jan KrausHTML, CSS & Javascript Architecture (extended version) - Jan Kraus
HTML, CSS & Javascript Architecture (extended version) - Jan Kraus
 
Generic Attack Detection - ph-Neutral 0x7d8
Generic Attack Detection - ph-Neutral 0x7d8Generic Attack Detection - ph-Neutral 0x7d8
Generic Attack Detection - ph-Neutral 0x7d8
 
Introduction to Node js
Introduction to Node jsIntroduction to Node js
Introduction to Node js
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.js
 

Semelhante a An overview of node.js

Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsVikash Singh
 
Tech io nodejs_20130531_v0.6
Tech io nodejs_20130531_v0.6Tech io nodejs_20130531_v0.6
Tech io nodejs_20130531_v0.6Ganesh Kondal
 
Day in a life of a node.js developer
Day in a life of a node.js developerDay in a life of a node.js developer
Day in a life of a node.js developerEdureka!
 
Day In A Life Of A Node.js Developer
Day In A Life Of A Node.js DeveloperDay In A Life Of A Node.js Developer
Day In A Life Of A Node.js DeveloperEdureka!
 
Node, express & sails
Node, express & sailsNode, express & sails
Node, express & sailsBrian Shannon
 
"Node.js vs workers — A comparison of two JavaScript runtimes", James M Snell
"Node.js vs workers — A comparison of two JavaScript runtimes", James M Snell"Node.js vs workers — A comparison of two JavaScript runtimes", James M Snell
"Node.js vs workers — A comparison of two JavaScript runtimes", James M SnellFwdays
 
Построение простого REST сервера на Node.js | Odessa Frontend Code challenge
Построение простого REST сервера на Node.js | Odessa Frontend Code challengeПостроение простого REST сервера на Node.js | Odessa Frontend Code challenge
Построение простого REST сервера на Node.js | Odessa Frontend Code challengeOdessaFrontend
 
Kalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect GuideKalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect GuideKalp Corporate
 
Node js (runtime environment + js library) platform
Node js (runtime environment + js library) platformNode js (runtime environment + js library) platform
Node js (runtime environment + js library) platformSreenivas Kappala
 
Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS drupalcampest
 

Semelhante a An overview of node.js (20)

Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Nodejs
NodejsNodejs
Nodejs
 
Proposal
ProposalProposal
Proposal
 
Tech io nodejs_20130531_v0.6
Tech io nodejs_20130531_v0.6Tech io nodejs_20130531_v0.6
Tech io nodejs_20130531_v0.6
 
Day in a life of a node.js developer
Day in a life of a node.js developerDay in a life of a node.js developer
Day in a life of a node.js developer
 
Day In A Life Of A Node.js Developer
Day In A Life Of A Node.js DeveloperDay In A Life Of A Node.js Developer
Day In A Life Of A Node.js Developer
 
Ferrara Linux Day 2011
Ferrara Linux Day 2011Ferrara Linux Day 2011
Ferrara Linux Day 2011
 
Node, express & sails
Node, express & sailsNode, express & sails
Node, express & sails
 
02 Node introduction
02 Node introduction02 Node introduction
02 Node introduction
 
Node js
Node jsNode js
Node js
 
Nodejs
NodejsNodejs
Nodejs
 
"Node.js vs workers — A comparison of two JavaScript runtimes", James M Snell
"Node.js vs workers — A comparison of two JavaScript runtimes", James M Snell"Node.js vs workers — A comparison of two JavaScript runtimes", James M Snell
"Node.js vs workers — A comparison of two JavaScript runtimes", James M Snell
 
Построение простого REST сервера на Node.js | Odessa Frontend Code challenge
Построение простого REST сервера на Node.js | Odessa Frontend Code challengeПостроение простого REST сервера на Node.js | Odessa Frontend Code challenge
Построение простого REST сервера на Node.js | Odessa Frontend Code challenge
 
Kalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect GuideKalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect Guide
 
Node js (runtime environment + js library) platform
Node js (runtime environment + js library) platformNode js (runtime environment + js library) platform
Node js (runtime environment + js library) platform
 
Real time web
Real time webReal time web
Real time web
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Node.js
Node.jsNode.js
Node.js
 
Beginners Node.js
Beginners Node.jsBeginners Node.js
Beginners Node.js
 
Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS
 

Mais de valuebound

Scaling Drupal for High Traffic Websites
Scaling Drupal for High Traffic WebsitesScaling Drupal for High Traffic Websites
Scaling Drupal for High Traffic Websitesvaluebound
 
Drupal 7 to Drupal 10 Migration A Fintech Strategic Blueprint (1).pdf
Drupal 7 to Drupal 10 Migration A Fintech Strategic Blueprint (1).pdfDrupal 7 to Drupal 10 Migration A Fintech Strategic Blueprint (1).pdf
Drupal 7 to Drupal 10 Migration A Fintech Strategic Blueprint (1).pdfvaluebound
 
How to Use DDEV to Streamline Your Drupal Development Process.
How to Use DDEV to Streamline Your Drupal Development Process.How to Use DDEV to Streamline Your Drupal Development Process.
How to Use DDEV to Streamline Your Drupal Development Process.valuebound
 
How to Use AWS to Automate Your IT Operation| Valuebound
How to Use AWS to Automate Your IT Operation| Valuebound How to Use AWS to Automate Your IT Operation| Valuebound
How to Use AWS to Automate Your IT Operation| Valuebound valuebound
 
How to Use Firebase to Send Push Notifications to React Native and Node.js Apps
How to Use Firebase to Send Push Notifications to React Native and Node.js AppsHow to Use Firebase to Send Push Notifications to React Native and Node.js Apps
How to Use Firebase to Send Push Notifications to React Native and Node.js Appsvaluebound
 
Mastering Drupal Theming
Mastering Drupal ThemingMastering Drupal Theming
Mastering Drupal Themingvaluebound
 
The Benefits of Cloud Engineering
The Benefits of Cloud EngineeringThe Benefits of Cloud Engineering
The Benefits of Cloud Engineeringvaluebound
 
Cloud Computing
Cloud ComputingCloud Computing
Cloud Computingvaluebound
 
The Future of Cloud Engineering: Emerging Trends and Technologies to Watch in...
The Future of Cloud Engineering: Emerging Trends and Technologies to Watch in...The Future of Cloud Engineering: Emerging Trends and Technologies to Watch in...
The Future of Cloud Engineering: Emerging Trends and Technologies to Watch in...valuebound
 
Deep dive into ChatGPT
Deep dive into ChatGPTDeep dive into ChatGPT
Deep dive into ChatGPTvaluebound
 
Content Creation Solution | Valuebound
Content Creation Solution | ValueboundContent Creation Solution | Valuebound
Content Creation Solution | Valueboundvaluebound
 
Road ahead for Drupal 8 contributed projects
Road ahead for Drupal 8 contributed projectsRoad ahead for Drupal 8 contributed projects
Road ahead for Drupal 8 contributed projectsvaluebound
 
Chatbot with RASA | Valuebound
Chatbot with RASA | ValueboundChatbot with RASA | Valuebound
Chatbot with RASA | Valueboundvaluebound
 
Drupal and Artificial Intelligence for Personalization
Drupal and Artificial Intelligence for Personalization Drupal and Artificial Intelligence for Personalization
Drupal and Artificial Intelligence for Personalization valuebound
 
Drupal growth in last year | Valuebound
Drupal growth in last year | ValueboundDrupal growth in last year | Valuebound
Drupal growth in last year | Valueboundvaluebound
 
BE NEW TO THE WORLD "BRAVE FROM CHROME"
BE NEW TO THE WORLD "BRAVE FROM CHROME"BE NEW TO THE WORLD "BRAVE FROM CHROME"
BE NEW TO THE WORLD "BRAVE FROM CHROME"valuebound
 
Event loop in browser
Event loop in browserEvent loop in browser
Event loop in browservaluebound
 
The Basics of MongoDB
The Basics of MongoDBThe Basics of MongoDB
The Basics of MongoDBvaluebound
 
React JS: A Secret Preview
React JS: A Secret PreviewReact JS: A Secret Preview
React JS: A Secret Previewvaluebound
 
Dependency Injection in Drupal 8
Dependency Injection in Drupal 8Dependency Injection in Drupal 8
Dependency Injection in Drupal 8valuebound
 

Mais de valuebound (20)

Scaling Drupal for High Traffic Websites
Scaling Drupal for High Traffic WebsitesScaling Drupal for High Traffic Websites
Scaling Drupal for High Traffic Websites
 
Drupal 7 to Drupal 10 Migration A Fintech Strategic Blueprint (1).pdf
Drupal 7 to Drupal 10 Migration A Fintech Strategic Blueprint (1).pdfDrupal 7 to Drupal 10 Migration A Fintech Strategic Blueprint (1).pdf
Drupal 7 to Drupal 10 Migration A Fintech Strategic Blueprint (1).pdf
 
How to Use DDEV to Streamline Your Drupal Development Process.
How to Use DDEV to Streamline Your Drupal Development Process.How to Use DDEV to Streamline Your Drupal Development Process.
How to Use DDEV to Streamline Your Drupal Development Process.
 
How to Use AWS to Automate Your IT Operation| Valuebound
How to Use AWS to Automate Your IT Operation| Valuebound How to Use AWS to Automate Your IT Operation| Valuebound
How to Use AWS to Automate Your IT Operation| Valuebound
 
How to Use Firebase to Send Push Notifications to React Native and Node.js Apps
How to Use Firebase to Send Push Notifications to React Native and Node.js AppsHow to Use Firebase to Send Push Notifications to React Native and Node.js Apps
How to Use Firebase to Send Push Notifications to React Native and Node.js Apps
 
Mastering Drupal Theming
Mastering Drupal ThemingMastering Drupal Theming
Mastering Drupal Theming
 
The Benefits of Cloud Engineering
The Benefits of Cloud EngineeringThe Benefits of Cloud Engineering
The Benefits of Cloud Engineering
 
Cloud Computing
Cloud ComputingCloud Computing
Cloud Computing
 
The Future of Cloud Engineering: Emerging Trends and Technologies to Watch in...
The Future of Cloud Engineering: Emerging Trends and Technologies to Watch in...The Future of Cloud Engineering: Emerging Trends and Technologies to Watch in...
The Future of Cloud Engineering: Emerging Trends and Technologies to Watch in...
 
Deep dive into ChatGPT
Deep dive into ChatGPTDeep dive into ChatGPT
Deep dive into ChatGPT
 
Content Creation Solution | Valuebound
Content Creation Solution | ValueboundContent Creation Solution | Valuebound
Content Creation Solution | Valuebound
 
Road ahead for Drupal 8 contributed projects
Road ahead for Drupal 8 contributed projectsRoad ahead for Drupal 8 contributed projects
Road ahead for Drupal 8 contributed projects
 
Chatbot with RASA | Valuebound
Chatbot with RASA | ValueboundChatbot with RASA | Valuebound
Chatbot with RASA | Valuebound
 
Drupal and Artificial Intelligence for Personalization
Drupal and Artificial Intelligence for Personalization Drupal and Artificial Intelligence for Personalization
Drupal and Artificial Intelligence for Personalization
 
Drupal growth in last year | Valuebound
Drupal growth in last year | ValueboundDrupal growth in last year | Valuebound
Drupal growth in last year | Valuebound
 
BE NEW TO THE WORLD "BRAVE FROM CHROME"
BE NEW TO THE WORLD "BRAVE FROM CHROME"BE NEW TO THE WORLD "BRAVE FROM CHROME"
BE NEW TO THE WORLD "BRAVE FROM CHROME"
 
Event loop in browser
Event loop in browserEvent loop in browser
Event loop in browser
 
The Basics of MongoDB
The Basics of MongoDBThe Basics of MongoDB
The Basics of MongoDB
 
React JS: A Secret Preview
React JS: A Secret PreviewReact JS: A Secret Preview
React JS: A Secret Preview
 
Dependency Injection in Drupal 8
Dependency Injection in Drupal 8Dependency Injection in Drupal 8
Dependency Injection in Drupal 8
 

Último

Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
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
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
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
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
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
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 

Último (20)

Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
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
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
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, ...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
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
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 

An overview of node.js

  • 1. An Overview of Node.js N. Kishorekumar https://www.drupal.org/u/nkishorekumar https://twitter.com/kishorekumar920
  • 2. ● Introduction ● Some (Confusing) Theory ● Few Examples ● A couple of weird diagrams ● Pics showing unbelievable benchmarks ● Some stuff from Internet What To Expect Ahead....
  • 3. ● V8 is an open source JavaScript engine developed by Google. ● Node.js runs on V8. ● It was created by Ryan Dahl in 2009. ● Is Open Source. It runs well on Linux systems, can also run on Windows systems. ● If you have worked on EventMachine (Ruby) or Python’s Twisted or Perl’s AnyEvent framework then following presentation is going to be very easy. Background
  • 4. ● In simple words Node.js is ‘server-side JavaScript’. ● In not-so-simple words Node.js is a high-performance network applications framework, well optimized for high concurrent environments. ● It’s a command line tool. ● In ‘Node.js’ , ‘.js’ doesn’t mean that its solely written in JavaScript. It is 40% JS and 60% C++. ● From the official site: ‘Node's goal is to provide an easy way to build scalable network programs’ - (from nodejs.org!) Introduction: Basic
  • 5. ● Node.js uses an event-driven, non-blocking I/O model, which makes it lightweight. (from nodejs.org!) ● It makes use of event-loops via JavaScript’s callback functionality to implement the non-blocking I/O. ● Programs for Node.js are written in JavaScript but not in the same JavaScript we are use to. There is no DOM implementation provided by Node.js, i.e. you cannot do this: var element = document.getElementById(‚elementId‛); ● Everything inside Node.js runs in a single-thread. Introduction: Advanced (Confusing)
  • 6. ● In an event-driven application, there is generally a main loop that listens for events, and then triggers a callback function when one of those events is detected. Some Theory : Event Driven
  • 7. ● Traditional I/O var result = db.query(‚select x from table_Y‛); doSomethingWith(result); //wait for result! doSomethingWithOutResult(); //execution is blocked! ● Non-traditional, Non-blocking I/O db.query(‚select x from table_Y”,function (result){ doSomethingWith(result); //wait for result! }); doSomethingWithOutResult(); //executes without any Delay! Some Theory: Non-Blocking I/O
  • 8. ● Install/build Node.js. (Yes! Windows installer is available!) ● Open your favorite editor and start typing JavaScript. ● When you are done, open cmd/terminal and type this: ‘node YOUR_FILE.js’ ● Here is a simple example, which prints ‘hello world’ setTimeout(function(){ console.log('world');},3000); console.log('hello'); //it prints ‘hello’ first and waits for 3 seconds and then prints ‘world’ Example 1: Getting Started & Hello World
  • 9. ● You can create an HTTP server and print ‘hello world’ on the browser in just 4 lines of JavaScript. (Example included) ● You can create a TCP server similar to HTTP server, in just 4 lines of JavaScript. (Example included) ● You can create a DNS server. ● You can create a Static File Server. ● You can create a Web Chat Application like GTalk in the browser. ● Node.js can also be used for creating online games, collaboration tools or anything which sends updates to the user in real-time. What Can You Do With Node.js ?
  • 10. ● 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"); Example 2 & 3 (HTTP Server & TCP Server)
  • 11. ● 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. ● More can be found at: ○ http://stackoverflow.com/questions/5062614/how-to- decide-when-to-use-nodejs When To Use Node.js ?
  • 12. Install nTwitter module using npm: Npm install ntwitter Code: var twitter = require('ntwitter'); var twit = new twitter({ consumer_key: ‘c_key’, consumer_secret: ‘c_secret’, access_token_key: ‘token_key’, access_token_secret: ‘token_secret’}); twit.stream('statuses/sample', function(stream) { stream.on('data', function (data) { console.log(data); }); }); Example 4: Twitter Streaming
  • 13. Click to add text Benchmarks
  • 14. ● CPU Heavy jobs : When you are doing heavy and CPU intensive calculations on server side, because event-loops are CPU hungry. ● CRUD - Node.js would be superfluous for simple HTML or CRUD applications ● 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: https://www.quora.com/What-are-the-disadvantages-of-using- Node-js When To Not Use Node.js
  • 15. ● 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 Appendix 1: Who Is Using Node.js In Production?
  • 16. ● Express – to make things simpler e.g. syntax, DB connections. ● Jade – HTML template system ● Socket.IO – to create real-time apps ● Nodemon – to monitor Node.js and push change automatically ● CoffeeScript – for easier JavaScript development ● Find out more about some widely used Node.js modules at: http://blog.nodejitsu.com/top-node-module-creators Appendix 2: Some Good Modules
  • 17. ● Watch this video at Youtube: http://www.youtube.com/watch?v=jo_B4LTHi3I ● Read the free O’reilly Book ‘Up and Running with Node.js’ http://ofps.oreilly.com/titles/9781449398583/ ● Visit www.nodejs.org for Info/News about Node.js ● Watch Node.js tutorials @ http://nodetuts.com/ ● For Info on MongoDB: http://www.mongodb.org/display/DOCS/Home ● For anything else Google! Appendix 3: Resource To Get Started