SlideShare a Scribd company logo
Intro to Node.js
Amy Hua
Agenda
What is Node.js?
What is non-blocking I/O?
When should you use Node?
Node vs Ruby on Rails
What is Node.js? | summary
• is a command-line tool that can be run as a regular web server and
lets one run Javascript programs
• utilizes the very fast V8 Javascript engine built in Google Chrome
• is very good when you need to do several things at the same time
• is event-based so all the wonderful Ajax like stuff can be done on
the server side
• lets us share code between the browser and the backend
Source: http://stackoverflow.com/questions/5062614/how-to-decide-when-to-use-nodejs
What is Node.js? | summary
• InfoWorld Technology of the Year Award (2012)
• 2nd most popular repo on Github
What is Node.js?
“Node is Javascript on the
server…done right”
“Javascript everywhere”
Sounds confusing:
• Node is not written in Javascript
• It is written in C++, but developers interact with Node
through the look and feel of Javascript
• ~20,000 lines of C++
• ~20,000 lines of Javascript
• Asynchronous server model
What is Node.js?
Node is a set of libraries written on top of Chrome‟s V8
Javascript Engine.
What is the V8 Javascript Engine?
• A Javascript engine is software that interprets & executes Javascript.
• V8 Javascript Engine is written in C++ (and so is Node) and is
extremely fast at running Javascript.
What is Node.js?
Announced in 2009, founded by Ryan Dahl.
Ryan Dahl originally built Node out of frustrations with
trying to build web servers in Ruby.
What is Node.js?
Extremely young.
• 2009: Ryan Dahl announced Node.js
• 2010: became somewhat stable
• 11/2011: “stuff works in windows”
• 6/2012: “stuff works better”
Node is still changing
What is Node.js?
Node.js demonstrates “how I/O should be done”
– Ryan Dahl
What is I/O?
What is Node.js?
event-driven, non-blocking I/O model
What is Node.js? | I/O models
Blocking I/O Model
Example: ways in which a server can process orders from
customers
Hi, my name is
Apache. How may
I take your order?
• The server serves one
customer at a time.
• As each customer is
deciding on their order, the
server sits and waits.
• When the customer decides
on an order, the server
processes their order and
moves on to the next
customer.
What is Node.js? | non-blocking I/O
Blocking I/O Model
Hmm… still
thinking...
OMG she’s blocking
me. I could have
ordered by now.
What is Node.js? | non-blocking I/O
Blocking I/O Model
Hmm… still
thinking...
OMG she’s blocking
me. I could have
ordered by now. Pseudocode:
order1 = db.query(“SELECT *
FROM menu WHERE preference =
most”)
order1.process
order2.process
What is Node.js? | non-blocking I/O
Blocking I/O Model
The more customers you want
to serve at once, the more
cashier lines you‟ll need.
Cashier lines ~ threads in
computing
Multi-threaded processing
Parallel code execution
Multiple CPUs run at a time,
utilizing shared resources
(memory)
What is Node.js? | non-blocking I/O
Non-Blocking I/O Model
I’m still thinking, but
callback to me when
I’m done.While he’s
thinking, I’ll
order the
salmon.
• Node loops through the
customers and polls them to
determine which ones are
ready to order.
• During a function‟s
queue, Node can listen to
another event.
• When the other customer is
finally ready to order, he‟ll
issue a callback.
• Asynchronous callbacks:
“come back to me when I’m
finished”
• function called at the
completion of a given
task.
What is Node.js? | non-blocking I/O
Non-Blocking I/O Model
I’m still thinking, but
callback to me when
I’m done.While he’s
thinking, I’ll
order the
salmon.
Node code
console.log(„Hello‟);
setTimeout(function () {
console.log(„World‟);
}, 5000);
console.log(„Bye‟);
// Outputs:
// Hello
// Bye
// World
Allows for high
concurrency
What is Node.js? | non-blocking I/O
Non-Blocking I/O Model
I’m still thinking, but
callback to me when
I’m done.While he’s
thinking, I’ll
order the
salmon.
Every function in Node
is non-blocking
Single-threaded
No parallel code
execution
Single CPU
What is Node.js? | non-blocking I/O
Node is great for
applications with high
concurrency
(Concurrency =
number of concurrent
clients or users)
What is Node.js? | non-blocking I/O
nginx: non-blocking I/O
apache: blocking I/O
Agenda
What is Node.js?
What is non-blocking I/O?
When should you use Node?
Node vs Ruby on Rails
When should you use Node?
Should you always use Node?
When should you use Node?
No
When should you use Node?
Use Node when:
cost of I/O > cost of more difficult to write code
Cons:
• Not useful for when I/O is light, CPU usage is high (e.g.,
video encoding software)
• Still very barebones, not a powerful framework yet
• You live on Mars
• can‟t utilize any code or libraries in the blocking-I/O world (or else
risk hanging your whole application)
Agenda
What is Node.js?
What is non-blocking I/O?
When should you use Node?
Node vs Ruby on Rails
Node.js vs Rails
Node.js Ruby on Rails
• Server framework. Requires
Express.js or Mongoose, etc.
• One language: Javascript (and all
of its pros and cons)
• Low-level, barebones framework
with freeform MVC. Requires
custom configuration of modules,
views, and helpers. Handpicking
over default configurations.
• Code sharing between server-side
and client-side JS processes
• Still evolving libraries and tools,
developing ecosystem
• No rapid prototyping
• Web framework
• Ruby, Javascript, SQL
• Full package, many built-in
functions, more out of the box
framework
• “Convention over Configuration” –
spend less time on
configuration, more on actual code
• Utilizes best practices
• Robust sources of libraries and
tools, large ecosystem
• Rapid prototyping
Questions

More Related Content

PPTX
Introduction Node.js
PPTX
Introduction to node.js
PDF
Philly Tech Week Introduction to NodeJS
PPTX
introduction to node.js
PDF
Original slides from Ryan Dahl's NodeJs intro talk
PDF
NodeJS for Beginner
PDF
NodeJS: an Introduction
PDF
NodeJS
Introduction Node.js
Introduction to node.js
Philly Tech Week Introduction to NodeJS
introduction to node.js
Original slides from Ryan Dahl's NodeJs intro talk
NodeJS for Beginner
NodeJS: an Introduction
NodeJS

What's hot (20)

PDF
Node Architecture and Getting Started with Express
PPT
Nodejs Event Driven Concurrency for Web Applications
KEY
node.js: Javascript's in your backend
PPTX
Introduction to Node.js
KEY
NodeJS
KEY
Introduction to node.js
KEY
Writing robust Node.js applications
PDF
Server Side Event Driven Programming
PDF
Building servers with Node.js
PDF
Getting started with developing Nodejs
PDF
Nodejs in Production
PPTX
Introduction to Node js
PPTX
Intro to Node.js (v1)
PPTX
node.js and native code extensions by example
KEY
A million connections and beyond - Node.js at scale
PPTX
Java script at backend nodejs
PDF
Introduction to Node.js: What, why and how?
PPTX
Introduction to NodeJS
PDF
Nodejs vatsal shah
Node Architecture and Getting Started with Express
Nodejs Event Driven Concurrency for Web Applications
node.js: Javascript's in your backend
Introduction to Node.js
NodeJS
Introduction to node.js
Writing robust Node.js applications
Server Side Event Driven Programming
Building servers with Node.js
Getting started with developing Nodejs
Nodejs in Production
Introduction to Node js
Intro to Node.js (v1)
node.js and native code extensions by example
A million connections and beyond - Node.js at scale
Java script at backend nodejs
Introduction to Node.js: What, why and how?
Introduction to NodeJS
Nodejs vatsal shah
Ad

Viewers also liked (20)

PPT
Directi Campus Recruitment (BizDev)
PPT
Async IO and Multithreading explained
PPTX
Event-driven IO server-side JavaScript environment based on V8 Engine
PDF
Recommendation Systems
PDF
Thousands of Threads and Blocking I/O
PDF
Asynchronous PHP and Real-time Messaging
PPT
Anemias
PDF
Smics2012 brochure
PDF
Basel Agenda 2016 during the Life Science Week 2016
PPTX
El calendario escolar 2013 2014 república dominicana
PDF
PDF
6 Apps Para Mejorar Tu Android Rendimiento del Teléfono
ODP
Migraciones 3 ° A
PPTX
Presentacion campamento verano la enseñanza 2013
PDF
Equal pay day essay contest 2016
PPT
Instituto Superior Paul Muller - Peru
PPT
Intro to Social Media
PDF
Social CaseHistory Forum 2012 - Email marketing e social media
PDF
Llista targeta pp_blava
PPTX
Los entornos digitales de enseñanza y aprendizaje
Directi Campus Recruitment (BizDev)
Async IO and Multithreading explained
Event-driven IO server-side JavaScript environment based on V8 Engine
Recommendation Systems
Thousands of Threads and Blocking I/O
Asynchronous PHP and Real-time Messaging
Anemias
Smics2012 brochure
Basel Agenda 2016 during the Life Science Week 2016
El calendario escolar 2013 2014 república dominicana
6 Apps Para Mejorar Tu Android Rendimiento del Teléfono
Migraciones 3 ° A
Presentacion campamento verano la enseñanza 2013
Equal pay day essay contest 2016
Instituto Superior Paul Muller - Peru
Intro to Social Media
Social CaseHistory Forum 2012 - Email marketing e social media
Llista targeta pp_blava
Los entornos digitales de enseñanza y aprendizaje
Ad

Similar to Intro to node and non blocking io (20)

PPTX
NodeJS and what is actually does
PDF
Node.js primer
PPTX
Kalp Corporate Node JS Perfect Guide
PDF
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
PDF
Developing realtime apps with Drupal and NodeJS
PPTX
02 Node introduction
PPTX
PDF
A first look into the Project Loom in Java
PPTX
What is Node.js
PPTX
Introduction to node.js by jiban
PDF
Nodejs presentation
ODP
Sfd2012Hanoi Nguyễn Hà Dương - Introduction to Node.js
ODP
Sfd hanoi2012 nguyen ha duong yang node.js-intro
PDF
Introduction to Node JS.pdf
PDF
Tech io nodejs_20130531_v0.6
PPTX
Quick introduction to nodeJs
PDF
Node, express & sails
PDF
Introduction to Node.js
PDF
Understand How Node.js and Core Features Works
PPTX
An overview of node.js
NodeJS and what is actually does
Node.js primer
Kalp Corporate Node JS Perfect Guide
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
Developing realtime apps with Drupal and NodeJS
02 Node introduction
A first look into the Project Loom in Java
What is Node.js
Introduction to node.js by jiban
Nodejs presentation
Sfd2012Hanoi Nguyễn Hà Dương - Introduction to Node.js
Sfd hanoi2012 nguyen ha duong yang node.js-intro
Introduction to Node JS.pdf
Tech io nodejs_20130531_v0.6
Quick introduction to nodeJs
Node, express & sails
Introduction to Node.js
Understand How Node.js and Core Features Works
An overview of node.js

Recently uploaded (20)

PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Empathic Computing: Creating Shared Understanding
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPT
Teaching material agriculture food technology
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Encapsulation theory and applications.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Network Security Unit 5.pdf for BCA BBA.
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Advanced methodologies resolving dimensionality complications for autism neur...
Empathic Computing: Creating Shared Understanding
Building Integrated photovoltaic BIPV_UPV.pdf
20250228 LYD VKU AI Blended-Learning.pptx
Teaching material agriculture food technology
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Unlocking AI with Model Context Protocol (MCP)
Encapsulation_ Review paper, used for researhc scholars
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Encapsulation theory and applications.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
The AUB Centre for AI in Media Proposal.docx
Per capita expenditure prediction using model stacking based on satellite ima...

Intro to node and non blocking io

  • 2. Agenda What is Node.js? What is non-blocking I/O? When should you use Node? Node vs Ruby on Rails
  • 3. What is Node.js? | summary • is a command-line tool that can be run as a regular web server and lets one run Javascript programs • utilizes the very fast V8 Javascript engine built in Google Chrome • is very good when you need to do several things at the same time • is event-based so all the wonderful Ajax like stuff can be done on the server side • lets us share code between the browser and the backend Source: http://stackoverflow.com/questions/5062614/how-to-decide-when-to-use-nodejs
  • 4. What is Node.js? | summary • InfoWorld Technology of the Year Award (2012) • 2nd most popular repo on Github
  • 5. What is Node.js? “Node is Javascript on the server…done right” “Javascript everywhere” Sounds confusing: • Node is not written in Javascript • It is written in C++, but developers interact with Node through the look and feel of Javascript • ~20,000 lines of C++ • ~20,000 lines of Javascript • Asynchronous server model
  • 6. What is Node.js? Node is a set of libraries written on top of Chrome‟s V8 Javascript Engine. What is the V8 Javascript Engine? • A Javascript engine is software that interprets & executes Javascript. • V8 Javascript Engine is written in C++ (and so is Node) and is extremely fast at running Javascript.
  • 7. What is Node.js? Announced in 2009, founded by Ryan Dahl. Ryan Dahl originally built Node out of frustrations with trying to build web servers in Ruby.
  • 8. What is Node.js? Extremely young. • 2009: Ryan Dahl announced Node.js • 2010: became somewhat stable • 11/2011: “stuff works in windows” • 6/2012: “stuff works better” Node is still changing
  • 9. What is Node.js? Node.js demonstrates “how I/O should be done” – Ryan Dahl What is I/O?
  • 10. What is Node.js? event-driven, non-blocking I/O model
  • 11. What is Node.js? | I/O models Blocking I/O Model Example: ways in which a server can process orders from customers Hi, my name is Apache. How may I take your order? • The server serves one customer at a time. • As each customer is deciding on their order, the server sits and waits. • When the customer decides on an order, the server processes their order and moves on to the next customer.
  • 12. What is Node.js? | non-blocking I/O Blocking I/O Model Hmm… still thinking... OMG she’s blocking me. I could have ordered by now.
  • 13. What is Node.js? | non-blocking I/O Blocking I/O Model Hmm… still thinking... OMG she’s blocking me. I could have ordered by now. Pseudocode: order1 = db.query(“SELECT * FROM menu WHERE preference = most”) order1.process order2.process
  • 14. What is Node.js? | non-blocking I/O Blocking I/O Model The more customers you want to serve at once, the more cashier lines you‟ll need. Cashier lines ~ threads in computing Multi-threaded processing Parallel code execution Multiple CPUs run at a time, utilizing shared resources (memory)
  • 15. What is Node.js? | non-blocking I/O Non-Blocking I/O Model I’m still thinking, but callback to me when I’m done.While he’s thinking, I’ll order the salmon. • Node loops through the customers and polls them to determine which ones are ready to order. • During a function‟s queue, Node can listen to another event. • When the other customer is finally ready to order, he‟ll issue a callback. • Asynchronous callbacks: “come back to me when I’m finished” • function called at the completion of a given task.
  • 16. What is Node.js? | non-blocking I/O Non-Blocking I/O Model I’m still thinking, but callback to me when I’m done.While he’s thinking, I’ll order the salmon. Node code console.log(„Hello‟); setTimeout(function () { console.log(„World‟); }, 5000); console.log(„Bye‟); // Outputs: // Hello // Bye // World Allows for high concurrency
  • 17. What is Node.js? | non-blocking I/O Non-Blocking I/O Model I’m still thinking, but callback to me when I’m done.While he’s thinking, I’ll order the salmon. Every function in Node is non-blocking Single-threaded No parallel code execution Single CPU
  • 18. What is Node.js? | non-blocking I/O Node is great for applications with high concurrency (Concurrency = number of concurrent clients or users)
  • 19. What is Node.js? | non-blocking I/O nginx: non-blocking I/O apache: blocking I/O
  • 20. Agenda What is Node.js? What is non-blocking I/O? When should you use Node? Node vs Ruby on Rails
  • 21. When should you use Node? Should you always use Node?
  • 22. When should you use Node? No
  • 23. When should you use Node? Use Node when: cost of I/O > cost of more difficult to write code Cons: • Not useful for when I/O is light, CPU usage is high (e.g., video encoding software) • Still very barebones, not a powerful framework yet • You live on Mars • can‟t utilize any code or libraries in the blocking-I/O world (or else risk hanging your whole application)
  • 24. Agenda What is Node.js? What is non-blocking I/O? When should you use Node? Node vs Ruby on Rails
  • 25. Node.js vs Rails Node.js Ruby on Rails • Server framework. Requires Express.js or Mongoose, etc. • One language: Javascript (and all of its pros and cons) • Low-level, barebones framework with freeform MVC. Requires custom configuration of modules, views, and helpers. Handpicking over default configurations. • Code sharing between server-side and client-side JS processes • Still evolving libraries and tools, developing ecosystem • No rapid prototyping • Web framework • Ruby, Javascript, SQL • Full package, many built-in functions, more out of the box framework • “Convention over Configuration” – spend less time on configuration, more on actual code • Utilizes best practices • Robust sources of libraries and tools, large ecosystem • Rapid prototyping

Editor's Notes

  • #6: Google V8 Javascript Engine is written in C++Node is a set of libraries on top of V8 to build networking applications.Node has the look and feel of JavascriptNode comes with its own Javascript REPLNode is sugar on top of Google V8
  • #12: Traditional Way:The server serves one customer at a time.As each customer is deciding on their order, the server sits and waits.When the customer decides on an order, the server processes their order and moves on to the next customer.
  • #13: Traditional Way:The server serves one customer at a time.As each customer is deciding on their order, the server sits and waits.When the customer decides on an order, the server processes their order and moves on to the next customer.
  • #14: Traditional Way:The server serves one customer at a time.As each customer is deciding on their order, the server sits and waits.When the customer decides on an order, the server processes their order and moves on to the next customer.
  • #15: Traditional Way:The server serves one customer at a time.As each customer is deciding on their order, the server sits and waits.When the customer decides on an order, the server processes their order and moves on to the next customer.