SlideShare uma empresa Scribd logo
1 de 16
Introduction to
Node.js
How does it work? What makes it different? When would you use

it? And most importantly, why does it matter?

Girish
Gangadharan

@appoosa
What is Node.js?
Development platform

Event-

Non-blocking I/O

driven

model

Built on Chrome's JavaScript

engine

“Node.js is lightweight and efficient which makes it perfect
for building fast, scalable network applications that run

across distributed devices.”
Wait a minute….

Umm…not
really.
JavaScript on the server

JavaScript was supposed to
be a server-side language as
well.
Netscape Enterprise Server

“ Netscape Enterprise Server 2.0 is the first web server to
support the Java(TM) and JavaScript(TM) programming
languages, enabling the creation, delivery and management of
live online applications.

”(March
1996)

Source: http://www.thefreelibrary.com/NETSCAPE+INTRODUCES+NETSCAPE+ENTERPRISE+SERVER(TM)+2.0-a018056425
Traditional web servers

Anyway, let’s see how web servers work
currently…
Current setup
Request 1

Thread 1

…

Request 2

Thread 2

…

Request n

Typically
….
Each request to a traditional web
server gets handed over to a
thread (picked from a limited
thread pool) for processing.

Thread m

(m < n)
(for a busy site, m could be a fraction of n)
How does it scale?

So if there are 10,000 requests
coming in at the same time, and
each requires executing a longrunning task (DB
transactions, network I/O, etc.) ….
How does node.js address it?

So what does node.js bring to the table?

Single thread processing.
And how does it work?
behind the
scenes

Source: http://www.aaronstannard.com/post/2011/12/14/Intro-to-NodeJS-for-NET-Developers.aspx
Simple “hello world” app
hello-world app in
node.js
// Load the http module to create an http server.
var http = require('http');
// Configure the HTTP server.
var server = http.createServer(function (request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.end("Hello, world");
});
// Listen on port 8000, IP defaults to 127.0.0.1
server.listen(3000);
// Log message to the terminal
console.log("Server running at http://127.0.0.1:3000/");
Demo

Let’s write some code.
What makes it different?
It’s JavaScript! (everybody know JavaScript,
right?)
Single threaded (avoid concurrency issues)
(single threaded out of the box, but still supports multi-threading)

Super efficient (can handle 100s of 1000s of
connections/minute)
Great for real-time applications (because of low latency)
Vibrant community (15,000+ packages)
And….it’s FREE! (no licensing costs, no expensive dev
tools)
Why does it matter?
It matters because just like with any other
technology, Node.js is not perfect.
Don’t start using it because it’s new and
shiny.
for example, it’s not the best solution for CPU intensive requests
processing

We don’t need another bubble.
When should you use it?
Multi user, real time apps
- mobile games, collaboration tools, chat rooms, etc.

APIs exposing JSON based DBs
- no need to do any JSON conversion (since it’s JavaScript)

Data Streaming
- Can process files as they’re still being uploaded (using
Streams)

Single page apps

- AJAX heavy apps can benefit from node’s low response
times
We’re done

Questions
?

Girish
Gangadharan

@appoosa

Mais conteúdo relacionado

Mais procurados

Ez Content Staging for the rest of us
Ez Content Staging for the rest of usEz Content Staging for the rest of us
Ez Content Staging for the rest of us
Gaetano Giunta
 
Nodejs - Building a RESTful API
Nodejs - Building a RESTful APINodejs - Building a RESTful API
Nodejs - Building a RESTful API
Sang Cù
 
Webconf nodejs-production-architecture
Webconf nodejs-production-architectureWebconf nodejs-production-architecture
Webconf nodejs-production-architecture
Ben Lin
 

Mais procurados (20)

Create Rest API in Nodejs
Create Rest API in Nodejs Create Rest API in Nodejs
Create Rest API in Nodejs
 
Node.js tutoria for beginner
Node.js tutoria for beginnerNode.js tutoria for beginner
Node.js tutoria for beginner
 
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
 
Welcome to ClojureScript
Welcome to ClojureScriptWelcome to ClojureScript
Welcome to ClojureScript
 
Ez Content Staging for the rest of us
Ez Content Staging for the rest of usEz Content Staging for the rest of us
Ez Content Staging for the rest of us
 
Node intro
Node introNode intro
Node intro
 
Intro to Node.js (v1)
Intro to Node.js (v1)Intro to Node.js (v1)
Intro to Node.js (v1)
 
Mern stack
Mern stackMern stack
Mern stack
 
Nodejs - Building a RESTful API
Nodejs - Building a RESTful APINodejs - Building a RESTful API
Nodejs - Building a RESTful API
 
Node.js on Azure
Node.js on AzureNode.js on Azure
Node.js on Azure
 
Introduction to node.js by jiban
Introduction to node.js by jibanIntroduction to node.js by jiban
Introduction to node.js by jiban
 
Webconf nodejs-production-architecture
Webconf nodejs-production-architectureWebconf nodejs-production-architecture
Webconf nodejs-production-architecture
 
Node js beginner
Node js beginnerNode js beginner
Node js beginner
 
Nodejs
NodejsNodejs
Nodejs
 
Frontend Track NodeJS
Frontend Track NodeJSFrontend Track NodeJS
Frontend Track NodeJS
 
Node js
Node jsNode js
Node js
 
ClojureScript@node
ClojureScript@nodeClojureScript@node
ClojureScript@node
 
What is Node.js
What is Node.jsWhat is Node.js
What is Node.js
 
GeekCampSG - Nodejs , Websockets and Realtime Web
GeekCampSG - Nodejs , Websockets and Realtime WebGeekCampSG - Nodejs , Websockets and Realtime Web
GeekCampSG - Nodejs , Websockets and Realtime Web
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
 

Destaque

Designing better-ux-workshop-3
Designing better-ux-workshop-3Designing better-ux-workshop-3
Designing better-ux-workshop-3
girish82
 
Designing better-ux-workshop-5
Designing better-ux-workshop-5Designing better-ux-workshop-5
Designing better-ux-workshop-5
girish82
 
Why we need to hire UX professionals
Why we need to hire UX professionalsWhy we need to hire UX professionals
Why we need to hire UX professionals
girish82
 
Designing better-ux-workshop-4
Designing better-ux-workshop-4Designing better-ux-workshop-4
Designing better-ux-workshop-4
girish82
 
Designing better-ux-workshop-2
Designing better-ux-workshop-2Designing better-ux-workshop-2
Designing better-ux-workshop-2
girish82
 
Designing better-ux
Designing better-uxDesigning better-ux
Designing better-ux
girish82
 
jQuery - 10 Time-Savers You (Maybe) Don't Know
jQuery - 10 Time-Savers You (Maybe) Don't KnowjQuery - 10 Time-Savers You (Maybe) Don't Know
jQuery - 10 Time-Savers You (Maybe) Don't Know
girish82
 

Destaque (7)

Designing better-ux-workshop-3
Designing better-ux-workshop-3Designing better-ux-workshop-3
Designing better-ux-workshop-3
 
Designing better-ux-workshop-5
Designing better-ux-workshop-5Designing better-ux-workshop-5
Designing better-ux-workshop-5
 
Why we need to hire UX professionals
Why we need to hire UX professionalsWhy we need to hire UX professionals
Why we need to hire UX professionals
 
Designing better-ux-workshop-4
Designing better-ux-workshop-4Designing better-ux-workshop-4
Designing better-ux-workshop-4
 
Designing better-ux-workshop-2
Designing better-ux-workshop-2Designing better-ux-workshop-2
Designing better-ux-workshop-2
 
Designing better-ux
Designing better-uxDesigning better-ux
Designing better-ux
 
jQuery - 10 Time-Savers You (Maybe) Don't Know
jQuery - 10 Time-Savers You (Maybe) Don't KnowjQuery - 10 Time-Savers You (Maybe) Don't Know
jQuery - 10 Time-Savers You (Maybe) Don't Know
 

Semelhante a Introduction to node

01 overview-servlets-and-environment-setup
01 overview-servlets-and-environment-setup01 overview-servlets-and-environment-setup
01 overview-servlets-and-environment-setup
dhrubo kayal
 
Docker intro
Docker introDocker intro
Docker intro
spiddy
 

Semelhante a Introduction to node (20)

HTTP, JSON, JavaScript, Map&Reduce built-in to MySQL
HTTP, JSON, JavaScript, Map&Reduce built-in to MySQLHTTP, JSON, JavaScript, Map&Reduce built-in to MySQL
HTTP, JSON, JavaScript, Map&Reduce built-in to MySQL
 
Node js
Node jsNode js
Node js
 
Original slides from Ryan Dahl's NodeJs intro talk
Original slides from Ryan Dahl's NodeJs intro talkOriginal slides from Ryan Dahl's NodeJs intro talk
Original slides from Ryan Dahl's NodeJs intro talk
 
Proposal
ProposalProposal
Proposal
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backend
 
HTTP Plugin for MySQL!
HTTP Plugin for MySQL!HTTP Plugin for MySQL!
HTTP Plugin for MySQL!
 
JAX London 2015: Java vs Nodejs
JAX London 2015: Java vs NodejsJAX London 2015: Java vs Nodejs
JAX London 2015: Java vs Nodejs
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Java vs. Java Script for enterprise web applications - Chris Bailey
Java vs. Java Script for enterprise web applications - Chris BaileyJava vs. Java Script for enterprise web applications - Chris Bailey
Java vs. Java Script for enterprise web applications - Chris Bailey
 
Nodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredevNodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredev
 
Nodejs
NodejsNodejs
Nodejs
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Building Hopsworks, a cloud-native managed feature store for machine learning
Building Hopsworks, a cloud-native managed feature store for machine learning Building Hopsworks, a cloud-native managed feature store for machine learning
Building Hopsworks, a cloud-native managed feature store for machine learning
 
Node.js 101 with Rami Sayar
Node.js 101 with Rami SayarNode.js 101 with Rami Sayar
Node.js 101 with Rami Sayar
 
01 overview-servlets-and-environment-setup
01 overview-servlets-and-environment-setup01 overview-servlets-and-environment-setup
01 overview-servlets-and-environment-setup
 
Nodejs
NodejsNodejs
Nodejs
 
Node.js: A Guided Tour
Node.js: A Guided TourNode.js: A Guided Tour
Node.js: A Guided Tour
 
Introduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.comIntroduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.com
 
Docker intro
Docker introDocker intro
Docker intro
 
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
 

Último

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
panagenda
 

Último (20)

"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 ...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
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
 
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
 
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
 
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...
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
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
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
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
 
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
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
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
 

Introduction to node

  • 1. Introduction to Node.js How does it work? What makes it different? When would you use it? And most importantly, why does it matter? Girish Gangadharan @appoosa
  • 2. What is Node.js? Development platform Event- Non-blocking I/O driven model Built on Chrome's JavaScript engine “Node.js is lightweight and efficient which makes it perfect for building fast, scalable network applications that run across distributed devices.”
  • 4. JavaScript on the server JavaScript was supposed to be a server-side language as well.
  • 5. Netscape Enterprise Server “ Netscape Enterprise Server 2.0 is the first web server to support the Java(TM) and JavaScript(TM) programming languages, enabling the creation, delivery and management of live online applications. ”(March 1996) Source: http://www.thefreelibrary.com/NETSCAPE+INTRODUCES+NETSCAPE+ENTERPRISE+SERVER(TM)+2.0-a018056425
  • 6. Traditional web servers Anyway, let’s see how web servers work currently…
  • 7. Current setup Request 1 Thread 1 … Request 2 Thread 2 … Request n Typically …. Each request to a traditional web server gets handed over to a thread (picked from a limited thread pool) for processing. Thread m (m < n) (for a busy site, m could be a fraction of n)
  • 8. How does it scale? So if there are 10,000 requests coming in at the same time, and each requires executing a longrunning task (DB transactions, network I/O, etc.) ….
  • 9. How does node.js address it? So what does node.js bring to the table? Single thread processing.
  • 10. And how does it work? behind the scenes Source: http://www.aaronstannard.com/post/2011/12/14/Intro-to-NodeJS-for-NET-Developers.aspx
  • 11. Simple “hello world” app hello-world app in node.js // Load the http module to create an http server. var http = require('http'); // Configure the HTTP server. var server = http.createServer(function (request, response) { response.writeHead(200, {"Content-Type": "text/plain"}); response.end("Hello, world"); }); // Listen on port 8000, IP defaults to 127.0.0.1 server.listen(3000); // Log message to the terminal console.log("Server running at http://127.0.0.1:3000/");
  • 13. What makes it different? It’s JavaScript! (everybody know JavaScript, right?) Single threaded (avoid concurrency issues) (single threaded out of the box, but still supports multi-threading) Super efficient (can handle 100s of 1000s of connections/minute) Great for real-time applications (because of low latency) Vibrant community (15,000+ packages) And….it’s FREE! (no licensing costs, no expensive dev tools)
  • 14. Why does it matter? It matters because just like with any other technology, Node.js is not perfect. Don’t start using it because it’s new and shiny. for example, it’s not the best solution for CPU intensive requests processing We don’t need another bubble.
  • 15. When should you use it? Multi user, real time apps - mobile games, collaboration tools, chat rooms, etc. APIs exposing JSON based DBs - no need to do any JSON conversion (since it’s JavaScript) Data Streaming - Can process files as they’re still being uploaded (using Streams) Single page apps - AJAX heavy apps can benefit from node’s low response times