SlideShare a Scribd company logo
NODE JS
by Gyuri Horak
WHAT IS NODE.JS
“Node has a clear purpose: provide an easy
way to build scalable network programs. It is
not a tool for every problem. Do not write a ray
tracer with Node. Do not write a web browser
with Node. Do however reach for Node if
tasked with writing a DNS server, DHCP
server, or even a video encoding server.”
Ryan Dahl
NODE.JS
● server-side javascript environment
● asynchronous event-driven model
● based on Google's V8 javascript engine
● open source, controlled by Joyent
● well documented
● lot of 3rd party modules
ASYNCHRONOUS?
● like Python's Twisted or Ruby's
EventMachine
● the event loop is hidden from the user
● non-blocking I/O (network, file, etc.)
● developers should think async
ASYNCHRONOUS!
mysql_select_db('db');
$result = mysql_query("SELECT * FROM table");
while ($row = mysql_fetch_array($result)) {
echo $row['data'];
}
echo "finished";
var mysql = require('mysql'),
client = mysql.createClient({
user: 'user',
password: 'password'
});
client.query('USE db');
client.query('SELECT * FROM table',
function selectCb(err, result, fields) {
console.log(result);
}
);
console.log("finished");
NO THREADS
● a node.js application is single threaded
● child_process.fork()
● I/O doesn't block, but you can:
for (var i = 0; i < 10000; i++) {
heavy_calculate_PI();
}
for (var i = 0; i < 10000; i++) {
setTimeout(heavy_calculate_PI, 0);
}
MODULES
● CommonJS Modules proposal
var hello = exports;
hello.say = function (name) { console.log("Hello "+name); }
var hello = require('./hello');
hello.say('Sanyi'); // "Hello Sanyi!"
● vs. AMD [Asynchronous Module Definition]
MODULES
● npm - node package manager
● more then 1000 listed on the wiki
● ~5000 repositories on github related to node.js
Web frameworks (MVC like fws, static file servers,
middlewares), database drivers (mysql, pgsql, sqlite,
mongodb, ...), templating, css engines, CMSs, SSL/crypto
fws, SMTP, TCP/IP, RPC, web socket, message queues,
class systems, testing fws, parsers (json, xml, command
line, parser generators), debugging utilities, compression,
graphics, payment gateways, i18n/l10n, coffeescript, full
text search, ...
HTTP MODULE
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello Worldn');
}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/');
$ node hello.js
Server running at http://127.0.0.1:1337/
SPEED
● Google V8 (used in Chrome as well), JIT
● may perform better then not optimized C++
(performance test)
● ~25 times faster than PHP (~10* CPython,
~2.5* PyPy)
● http module outperforms apache, sometimes
even nginx
● typical setup: multiple node.js instances
running behind an nginx (or node.js) proxy
SPEED OF HELLO.JS
50000 requests
● 1 client: 2211 r/s (apache: 2991) (nginx: 4009)
● 100 clients: 8088 r/s (apache: 12520) (nginx: 14021)
● 1000 clients: 6924 r/s (apache: crbp, 5693, 1356 failed)
(nginx: 11603, error: 235)
● 10000 clients: 5786 r/s (C10k problem?) (apache: crbp,
3956, 6421 failed) (nginx: 5991, error: 23137)
● 20000 clients: 4559 r/s ... (apache: crbp, 2399, 9552
failed) (nginx: -)
jsdom
● DOM implementation for node.js
● almost everything works
● YUI 3, jQuery, ...
● unit testing web applications
● rendering and manipulating content on
server side
HOSTING
● easy to install
○ very few dependecies
○ ./configure && make
● easy to manage
○ no need for webserver
● Lot of managed node.js hosting providers:
Heroku, no.de, CloudFoundry, dotCloud, ...
EXAMPLE PROJECTS
● Calipso - CMS based on node.js
● 64squares - Real time chess on facebook
● Hummingbird - real time visitor statistics
● Kraken.io - image optimizer
● Word2 - MMO word game
● ...

More Related Content

PDF
Node
PDF
DSSH: Innovation in SSH
PDF
Dssh @ Confidence, Prague 2010
PDF
Server Side Event Driven Programming
PDF
Rapid API development on MongoDB
PPTX
NodeJS Concurrency
PPTX
Node js introduction
PDF
Nodejs presentation
Node
DSSH: Innovation in SSH
Dssh @ Confidence, Prague 2010
Server Side Event Driven Programming
Rapid API development on MongoDB
NodeJS Concurrency
Node js introduction
Nodejs presentation

What's hot (20)

PDF
Use Node.js to create a REST API
PDF
Socket programming, and openresty
PDF
Fundamental of Node.JS - Internship Presentation - Week7
PPTX
Future of NodeJS
KEY
node.js dao
PDF
Meetup RomaJS - introduzione interattiva a Node.js - Luca Lanziani - Codemoti...
PPTX
My journey from PHP to Node.js
PDF
Node.js concurrency
PDF
Introduction to REST API with Node.js
ODP
IT Operations for Web Developers
PDF
(C)NodeJS
PPTX
Node.js tutoria for beginner
PPTX
3 Things Everyone Knows About Node JS That You Don't
PPTX
NodeJS
PPT
Ferrara Linux Day 2011
ODP
WebSockets with PHP: Mission impossible
KEY
Jugando con websockets en nodeJS
PDF
Node js first look - 2016
PPTX
Basics of Node.js
Use Node.js to create a REST API
Socket programming, and openresty
Fundamental of Node.JS - Internship Presentation - Week7
Future of NodeJS
node.js dao
Meetup RomaJS - introduzione interattiva a Node.js - Luca Lanziani - Codemoti...
My journey from PHP to Node.js
Node.js concurrency
Introduction to REST API with Node.js
IT Operations for Web Developers
(C)NodeJS
Node.js tutoria for beginner
3 Things Everyone Knows About Node JS That You Don't
NodeJS
Ferrara Linux Day 2011
WebSockets with PHP: Mission impossible
Jugando con websockets en nodeJS
Node js first look - 2016
Basics of Node.js
Ad

Viewers also liked (6)

PDF
Node js quick-tour_v2
PDF
About Node.js
PDF
Introduction to Node.js
PPT
Node js presentation
KEY
Node.js ― Hello, world! の1歩先へ。
PDF
Modern UI Development With Node.js
Node js quick-tour_v2
About Node.js
Introduction to Node.js
Node js presentation
Node.js ― Hello, world! の1歩先へ。
Modern UI Development With Node.js
Ad

Similar to Node.js (20)

PDF
Original slides from Ryan Dahl's NodeJs intro talk
PDF
Event driven programming -- Node.JS
PDF
Cape Cod Web Technology Meetup - 2
PDF
Node.js for Rubists
PPTX
PDF
NodeJS for Beginner
PDF
soft-shake.ch - Hands on Node.js
PDF
Node.js - async for the rest of us.
PPTX
introduction to node.js
PPTX
An overview of node.js
PPTX
Introduction to Node.js
PDF
Node js introduction
ODP
Introduce about Nodejs - duyetdev.com
PPTX
PDF
New Jersey Red Hat Users Group Presentation: Provisioning anywhere
PDF
Nodejs a-practical-introduction-oredev
PPT
Node js beginner
PDF
Introduction to WAMP, a protocol enabling PUB/SUB and RPC over Websocket
PDF
Построение простого REST сервера на Node.js | Odessa Frontend Code challenge
PDF
NodeJS
Original slides from Ryan Dahl's NodeJs intro talk
Event driven programming -- Node.JS
Cape Cod Web Technology Meetup - 2
Node.js for Rubists
NodeJS for Beginner
soft-shake.ch - Hands on Node.js
Node.js - async for the rest of us.
introduction to node.js
An overview of node.js
Introduction to Node.js
Node js introduction
Introduce about Nodejs - duyetdev.com
New Jersey Red Hat Users Group Presentation: Provisioning anywhere
Nodejs a-practical-introduction-oredev
Node js beginner
Introduction to WAMP, a protocol enabling PUB/SUB and RPC over Websocket
Построение простого REST сервера на Node.js | Odessa Frontend Code challenge
NodeJS

More from EU Edge (16)

PDF
Synchronization with CouchDB and PouchDB
PDF
How I learned to Stop Worrying and Love the inline-block
PDF
What is python
PDF
Advanced python
PDF
WebGL
PDF
Python alapu mobil backend
PDF
Res tful services
PDF
Open gl
PDF
Google glass a developers perspective
PDF
Google glass ict day presentation
PDF
How does it work the keyboard
PDF
Node webkit-meetup
PDF
Frontend meetup 2014.06.25
PDF
Eu edge intro
PDF
Halado css eu edge
PDF
Miért jó oktatóanyagot készíteni?
Synchronization with CouchDB and PouchDB
How I learned to Stop Worrying and Love the inline-block
What is python
Advanced python
WebGL
Python alapu mobil backend
Res tful services
Open gl
Google glass a developers perspective
Google glass ict day presentation
How does it work the keyboard
Node webkit-meetup
Frontend meetup 2014.06.25
Eu edge intro
Halado css eu edge
Miért jó oktatóanyagot készíteni?

Recently uploaded (20)

PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
ai tools demonstartion for schools and inter college
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
top salesforce developer skills in 2025.pdf
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
Transform Your Business with a Software ERP System
PDF
Digital Strategies for Manufacturing Companies
PDF
Understanding Forklifts - TECH EHS Solution
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
L1 - Introduction to python Backend.pptx
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
System and Network Administration Chapter 2
PPTX
Essential Infomation Tech presentation.pptx
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PPTX
Introduction to Artificial Intelligence
How Creative Agencies Leverage Project Management Software.pdf
Upgrade and Innovation Strategies for SAP ERP Customers
ai tools demonstartion for schools and inter college
Design an Analysis of Algorithms II-SECS-1021-03
CHAPTER 2 - PM Management and IT Context
top salesforce developer skills in 2025.pdf
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Transform Your Business with a Software ERP System
Digital Strategies for Manufacturing Companies
Understanding Forklifts - TECH EHS Solution
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
L1 - Introduction to python Backend.pptx
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Odoo Companies in India – Driving Business Transformation.pdf
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
System and Network Administration Chapter 2
Essential Infomation Tech presentation.pptx
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Introduction to Artificial Intelligence

Node.js

  • 2. WHAT IS NODE.JS “Node has a clear purpose: provide an easy way to build scalable network programs. It is not a tool for every problem. Do not write a ray tracer with Node. Do not write a web browser with Node. Do however reach for Node if tasked with writing a DNS server, DHCP server, or even a video encoding server.” Ryan Dahl
  • 3. NODE.JS ● server-side javascript environment ● asynchronous event-driven model ● based on Google's V8 javascript engine ● open source, controlled by Joyent ● well documented ● lot of 3rd party modules
  • 4. ASYNCHRONOUS? ● like Python's Twisted or Ruby's EventMachine ● the event loop is hidden from the user ● non-blocking I/O (network, file, etc.) ● developers should think async
  • 5. ASYNCHRONOUS! mysql_select_db('db'); $result = mysql_query("SELECT * FROM table"); while ($row = mysql_fetch_array($result)) { echo $row['data']; } echo "finished"; var mysql = require('mysql'), client = mysql.createClient({ user: 'user', password: 'password' }); client.query('USE db'); client.query('SELECT * FROM table', function selectCb(err, result, fields) { console.log(result); } ); console.log("finished");
  • 6. NO THREADS ● a node.js application is single threaded ● child_process.fork() ● I/O doesn't block, but you can: for (var i = 0; i < 10000; i++) { heavy_calculate_PI(); } for (var i = 0; i < 10000; i++) { setTimeout(heavy_calculate_PI, 0); }
  • 7. MODULES ● CommonJS Modules proposal var hello = exports; hello.say = function (name) { console.log("Hello "+name); } var hello = require('./hello'); hello.say('Sanyi'); // "Hello Sanyi!" ● vs. AMD [Asynchronous Module Definition]
  • 8. MODULES ● npm - node package manager ● more then 1000 listed on the wiki ● ~5000 repositories on github related to node.js Web frameworks (MVC like fws, static file servers, middlewares), database drivers (mysql, pgsql, sqlite, mongodb, ...), templating, css engines, CMSs, SSL/crypto fws, SMTP, TCP/IP, RPC, web socket, message queues, class systems, testing fws, parsers (json, xml, command line, parser generators), debugging utilities, compression, graphics, payment gateways, i18n/l10n, coffeescript, full text search, ...
  • 9. HTTP MODULE var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello Worldn'); }).listen(1337, "127.0.0.1"); console.log('Server running at http://127.0.0.1:1337/'); $ node hello.js Server running at http://127.0.0.1:1337/
  • 10. SPEED ● Google V8 (used in Chrome as well), JIT ● may perform better then not optimized C++ (performance test) ● ~25 times faster than PHP (~10* CPython, ~2.5* PyPy) ● http module outperforms apache, sometimes even nginx ● typical setup: multiple node.js instances running behind an nginx (or node.js) proxy
  • 11. SPEED OF HELLO.JS 50000 requests ● 1 client: 2211 r/s (apache: 2991) (nginx: 4009) ● 100 clients: 8088 r/s (apache: 12520) (nginx: 14021) ● 1000 clients: 6924 r/s (apache: crbp, 5693, 1356 failed) (nginx: 11603, error: 235) ● 10000 clients: 5786 r/s (C10k problem?) (apache: crbp, 3956, 6421 failed) (nginx: 5991, error: 23137) ● 20000 clients: 4559 r/s ... (apache: crbp, 2399, 9552 failed) (nginx: -)
  • 12. jsdom ● DOM implementation for node.js ● almost everything works ● YUI 3, jQuery, ... ● unit testing web applications ● rendering and manipulating content on server side
  • 13. HOSTING ● easy to install ○ very few dependecies ○ ./configure && make ● easy to manage ○ no need for webserver ● Lot of managed node.js hosting providers: Heroku, no.de, CloudFoundry, dotCloud, ...
  • 14. EXAMPLE PROJECTS ● Calipso - CMS based on node.js ● 64squares - Real time chess on facebook ● Hummingbird - real time visitor statistics ● Kraken.io - image optimizer ● Word2 - MMO word game ● ...