SlideShare a Scribd company logo
node.js Fast event based web application development Wien, 7. April 2011 Gerhard Hipfinger
What is node.js? A JavaScript runtime Based on Googles V8 JavaScript engine High performance async event handling Module system, I/O system bindings, supports all common network protocols
Availability Available on all major platforms and on Windows too (via Cygwin or MinGW)
Module Management You want to use module management as there are many available! Over 1100 NPM is your friend curl http://npmjs.org/install.sh | sh npm install express
Obligatory  Hello, World! console.log('Hello, node.js World!'); > node hello.js Hello, node.js World! Create file hello.js with the content: Than type:
Design Goals Only a small core library Extensible module system Non blocking I/O As close to system calls as possible
Non Blocking I/O First we look at traditional blocking I/O I/O is serialized and the execution time is sum(opA, opB) var a = getSomethingFromDatabase(); c onsole.log(a); v ar b =  getSomethingFromDatabase(); console.log(b);
Non Blocking I/O getSomethingFromDatabase(paramA, function(result) { console.log(result); }); getSomethingFromDatabase(paramB function(result) { console.log(result); }); Both queries are handled in an event queue and don't block each other Execution time is MAX(op1,op2)
Non Blocking I/O node.js uses epoll, kqueue or whatever is available at the underlying operating system So I/O does not waste your CPU cycles No busy waiting! Thread pool is used for everything else
(No) Threads The rest of your app is single threaded Easy programming model but is not useful for all kinds of apps
Your Webserver in 6 LOC var  http = require('http'); http.createServer( function  (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World\n'); }).listen(8888, "127.0.0.1"); console.log('Server running at http://127.0.0.1:8888/'); Pretty simple, isn't it?
Ever needed to poll for filechange? var fs = require('fs'); fs.watchFile(__filename, function() { console.log('I was changed!'); process.exit(0); });
So what can I do with node.js node.js is great for all I/O centric tasks Nearly all network apps are I/O centric (web or application server, socket server and so on)
node.js is good for... Web applications Streaming Unix tools (yeah, you can start your files with  #!/usr/bin/node )
Don't use it for... CPU intense apps with few I/O Apps that need huge memory (V8 has a 1.9G limit) Multiple cores need multiple processes (single threaded)
Modules you will fall in love with Express Socket.IO Cradle (CouchDB module)
There is room for improvement Tool support Debugging Error reporting Windows support (when you realy want a Windows server) XML support
JavaScript Support Node JS contains CommonsJS EcmaScript5 Usable node API
Integration Great support for NonSQL stores: CouchDB,  Redis But you still can use your RDB -> modules for all major databases
Resources http://nodejs.org/ https://github.com/joyent/node/wiki/modules http://expressjs.com/ http://socket.io/ You will need a good JavaScript understanding http://oreilly.com/catalog/9780596517748
Gerhard Hipfinger openForce Information Technology GesmbH Dresdner Str. 108 / 3. Stock / Top 11 1200 Wien TEL +43 1 3191775 FAX +43 1 3191775-20 http://openforce.com
Ad

Recommended

CouchApp - Build scalable web applications and relax
CouchApp - Build scalable web applications and relax
openForce Information Technology GesmbH
 
루비가 얼랭에 빠진 날
루비가 얼랭에 빠진 날
Sukjoon Kim
 
Real-Time Python Web: Gevent and Socket.io
Real-Time Python Web: Gevent and Socket.io
Rick Copeland
 
Server side scripting smack down - Node.js vs PHP
Server side scripting smack down - Node.js vs PHP
Marc Gear
 
Presentation of JSConf.eu
Presentation of JSConf.eu
Fredrik Wendt
 
Introduction tomongodb
Introduction tomongodb
Lee Theobald
 
Html5, css3, canvas, svg and webgl
Html5, css3, canvas, svg and webgl
Kilian Valkhof
 
Selenium sandwich-3: Being where you aren't.
Selenium sandwich-3: Being where you aren't.
Workhorse Computing
 
Lies, Damn Lies, and Benchmarks
Lies, Damn Lies, and Benchmarks
Workhorse Computing
 
Web::Scraper
Web::Scraper
Tatsuhiko Miyagawa
 
Task Scheduling and Asynchronous Processing Evolved. Zend Server Job Queue
Task Scheduling and Asynchronous Processing Evolved. Zend Server Job Queue
Sam Hennessy
 
Designing net-aws-glacier
Designing net-aws-glacier
Workhorse Computing
 
hacking with node.JS
hacking with node.JS
Harsha Vashisht
 
Front End Development Automation with Grunt
Front End Development Automation with Grunt
Ladies Who Code
 
Introduction to NodeJS with LOLCats
Introduction to NodeJS with LOLCats
Derek Anderson
 
Scalable web application architecture
Scalable web application architecture
postrational
 
Modern Perl Web Development with Dancer
Modern Perl Web Development with Dancer
Dave Cross
 
Selenium Sandwich Part 1: Data driven Selenium
Selenium Sandwich Part 1: Data driven Selenium
Workhorse Computing
 
Modern Perl
Modern Perl
Dave Cross
 
Node.js
Node.js
Jan Dillmann
 
Selenium sandwich-2
Selenium sandwich-2
Workhorse Computing
 
Node.js Lightning Talk
Node.js Lightning Talk
CodeSlice
 
Rush, a shell that will yield to you
Rush, a shell that will yield to you
guestdd9d06
 
Perl: Hate it for the Right Reasons
Perl: Hate it for the Right Reasons
Matt Follett
 
Djangocon 2014 angular + django
Djangocon 2014 angular + django
Nina Zakharenko
 
Forget Grunt and Gulp! Webpack and NPM rule them all!
Forget Grunt and Gulp! Webpack and NPM rule them all!
Derek Willian Stavis
 
HTML5 tutorial: canvas, offfline & sockets
HTML5 tutorial: canvas, offfline & sockets
Remy Sharp
 
MongoDB and Node.js
MongoDB and Node.js
Norberto Leite
 
An overview of node.js
An overview of node.js
valuebound
 
Nodejs
Nodejs
Vinod Kumar Marupu
 

More Related Content

What's hot (20)

Lies, Damn Lies, and Benchmarks
Lies, Damn Lies, and Benchmarks
Workhorse Computing
 
Web::Scraper
Web::Scraper
Tatsuhiko Miyagawa
 
Task Scheduling and Asynchronous Processing Evolved. Zend Server Job Queue
Task Scheduling and Asynchronous Processing Evolved. Zend Server Job Queue
Sam Hennessy
 
Designing net-aws-glacier
Designing net-aws-glacier
Workhorse Computing
 
hacking with node.JS
hacking with node.JS
Harsha Vashisht
 
Front End Development Automation with Grunt
Front End Development Automation with Grunt
Ladies Who Code
 
Introduction to NodeJS with LOLCats
Introduction to NodeJS with LOLCats
Derek Anderson
 
Scalable web application architecture
Scalable web application architecture
postrational
 
Modern Perl Web Development with Dancer
Modern Perl Web Development with Dancer
Dave Cross
 
Selenium Sandwich Part 1: Data driven Selenium
Selenium Sandwich Part 1: Data driven Selenium
Workhorse Computing
 
Modern Perl
Modern Perl
Dave Cross
 
Node.js
Node.js
Jan Dillmann
 
Selenium sandwich-2
Selenium sandwich-2
Workhorse Computing
 
Node.js Lightning Talk
Node.js Lightning Talk
CodeSlice
 
Rush, a shell that will yield to you
Rush, a shell that will yield to you
guestdd9d06
 
Perl: Hate it for the Right Reasons
Perl: Hate it for the Right Reasons
Matt Follett
 
Djangocon 2014 angular + django
Djangocon 2014 angular + django
Nina Zakharenko
 
Forget Grunt and Gulp! Webpack and NPM rule them all!
Forget Grunt and Gulp! Webpack and NPM rule them all!
Derek Willian Stavis
 
HTML5 tutorial: canvas, offfline & sockets
HTML5 tutorial: canvas, offfline & sockets
Remy Sharp
 
MongoDB and Node.js
MongoDB and Node.js
Norberto Leite
 
Task Scheduling and Asynchronous Processing Evolved. Zend Server Job Queue
Task Scheduling and Asynchronous Processing Evolved. Zend Server Job Queue
Sam Hennessy
 
Front End Development Automation with Grunt
Front End Development Automation with Grunt
Ladies Who Code
 
Introduction to NodeJS with LOLCats
Introduction to NodeJS with LOLCats
Derek Anderson
 
Scalable web application architecture
Scalable web application architecture
postrational
 
Modern Perl Web Development with Dancer
Modern Perl Web Development with Dancer
Dave Cross
 
Selenium Sandwich Part 1: Data driven Selenium
Selenium Sandwich Part 1: Data driven Selenium
Workhorse Computing
 
Node.js Lightning Talk
Node.js Lightning Talk
CodeSlice
 
Rush, a shell that will yield to you
Rush, a shell that will yield to you
guestdd9d06
 
Perl: Hate it for the Right Reasons
Perl: Hate it for the Right Reasons
Matt Follett
 
Djangocon 2014 angular + django
Djangocon 2014 angular + django
Nina Zakharenko
 
Forget Grunt and Gulp! Webpack and NPM rule them all!
Forget Grunt and Gulp! Webpack and NPM rule them all!
Derek Willian Stavis
 
HTML5 tutorial: canvas, offfline & sockets
HTML5 tutorial: canvas, offfline & sockets
Remy Sharp
 

Similar to node.js - Fast event based web application development (20)

An overview of node.js
An overview of node.js
valuebound
 
Nodejs
Nodejs
Vinod Kumar Marupu
 
Introduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.com
Van-Duyet Le
 
Proposal
Proposal
Constantine Priemski
 
NodeJS
NodeJS
Predhin Sapru
 
Introduction to Node.js
Introduction to Node.js
Vikash Singh
 
Kalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect Guide
Kalp Corporate
 
Nodejs Intro Part One
Nodejs Intro Part One
Budh Ram Gurung
 
Node.js - A practical introduction (v2)
Node.js - A practical introduction (v2)
Felix Geisendörfer
 
Nodejs presentation
Nodejs presentation
Arvind Devaraj
 
NodeJS for Beginner
NodeJS for Beginner
Apaichon Punopas
 
Node.js Workshop - Sela SDP 2015
Node.js Workshop - Sela SDP 2015
Nir Noy
 
Jaap : node, npm & grunt
Jaap : node, npm & grunt
Bertrand Chevrier
 
NodeJS guide for beginners
NodeJS guide for beginners
Enoch Joshua
 
GeekCampSG - Nodejs , Websockets and Realtime Web
GeekCampSG - Nodejs , Websockets and Realtime Web
Bhagaban Behera
 
Web with Nodejs
Web with Nodejs
Naman Gupta
 
Node.js for beginner
Node.js for beginner
Sarunyhot Suwannachoti
 
Introduction to Node.js: What, why and how?
Introduction to Node.js: What, why and how?
Christian Joudrey
 
Introduction to node.js by jiban
Introduction to node.js by jiban
Jibanananda Sana
 
Intro to node and non blocking io
Intro to node and non blocking io
Amy Hua
 
An overview of node.js
An overview of node.js
valuebound
 
Introduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.com
Van-Duyet Le
 
Introduction to Node.js
Introduction to Node.js
Vikash Singh
 
Kalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect Guide
Kalp Corporate
 
Node.js - A practical introduction (v2)
Node.js - A practical introduction (v2)
Felix Geisendörfer
 
Node.js Workshop - Sela SDP 2015
Node.js Workshop - Sela SDP 2015
Nir Noy
 
NodeJS guide for beginners
NodeJS guide for beginners
Enoch Joshua
 
GeekCampSG - Nodejs , Websockets and Realtime Web
GeekCampSG - Nodejs , Websockets and Realtime Web
Bhagaban Behera
 
Introduction to Node.js: What, why and how?
Introduction to Node.js: What, why and how?
Christian Joudrey
 
Introduction to node.js by jiban
Introduction to node.js by jiban
Jibanananda Sana
 
Intro to node and non blocking io
Intro to node and non blocking io
Amy Hua
 
Ad

More from openForce Information Technology GesmbH (7)

openExperts Talk - 12 Jahre agiles Manifest
openExperts Talk - 12 Jahre agiles Manifest
openForce Information Technology GesmbH
 
openExperts Talk - Kunden an die Macht
openExperts Talk - Kunden an die Macht
openForce Information Technology GesmbH
 
openExperts Talk: die Cloud und ich
openExperts Talk: die Cloud und ich
openForce Information Technology GesmbH
 
Web Testen mit Selenium
Web Testen mit Selenium
openForce Information Technology GesmbH
 
Sonar - Software Qualitätsmanagement ohne Schmerzen
Sonar - Software Qualitätsmanagement ohne Schmerzen
openForce Information Technology GesmbH
 
jQuery & CouchDB - Die zukünftige Webentwicklung?
jQuery & CouchDB - Die zukünftige Webentwicklung?
openForce Information Technology GesmbH
 
Wicket Kurzübersicht
Wicket Kurzübersicht
openForce Information Technology GesmbH
 
Ad

Recently uploaded (20)

Cyber Defense Matrix Workshop - RSA Conference
Cyber Defense Matrix Workshop - RSA Conference
Priyanka Aash
 
Daily Lesson Log MATATAG ICT TEchnology 8
Daily Lesson Log MATATAG ICT TEchnology 8
LOIDAALMAZAN3
 
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Priyanka Aash
 
Quantum AI: Where Impossible Becomes Probable
Quantum AI: Where Impossible Becomes Probable
Saikat Basu
 
Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
 
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Josef Weingand
 
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
digitaljignect
 
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
 
Techniques for Automatic Device Identification and Network Assignment.pdf
Techniques for Automatic Device Identification and Network Assignment.pdf
Priyanka Aash
 
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
 
cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
 
Database Benchmarking for Performance Masterclass: Session 2 - Data Modeling ...
Database Benchmarking for Performance Masterclass: Session 2 - Data Modeling ...
ScyllaDB
 
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Priyanka Aash
 
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
Earley Information Science
 
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
 
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
You are not excused! How to avoid security blind spots on the way to production
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
 
Cyber Defense Matrix Workshop - RSA Conference
Cyber Defense Matrix Workshop - RSA Conference
Priyanka Aash
 
Daily Lesson Log MATATAG ICT TEchnology 8
Daily Lesson Log MATATAG ICT TEchnology 8
LOIDAALMAZAN3
 
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Priyanka Aash
 
Quantum AI: Where Impossible Becomes Probable
Quantum AI: Where Impossible Becomes Probable
Saikat Basu
 
Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
 
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Josef Weingand
 
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
digitaljignect
 
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
 
Techniques for Automatic Device Identification and Network Assignment.pdf
Techniques for Automatic Device Identification and Network Assignment.pdf
Priyanka Aash
 
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
 
cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
 
Database Benchmarking for Performance Masterclass: Session 2 - Data Modeling ...
Database Benchmarking for Performance Masterclass: Session 2 - Data Modeling ...
ScyllaDB
 
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Priyanka Aash
 
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
Earley Information Science
 
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
 
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
You are not excused! How to avoid security blind spots on the way to production
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
 

node.js - Fast event based web application development

  • 1. node.js Fast event based web application development Wien, 7. April 2011 Gerhard Hipfinger
  • 2. What is node.js? A JavaScript runtime Based on Googles V8 JavaScript engine High performance async event handling Module system, I/O system bindings, supports all common network protocols
  • 3. Availability Available on all major platforms and on Windows too (via Cygwin or MinGW)
  • 4. Module Management You want to use module management as there are many available! Over 1100 NPM is your friend curl http://npmjs.org/install.sh | sh npm install express
  • 5. Obligatory Hello, World! console.log('Hello, node.js World!'); > node hello.js Hello, node.js World! Create file hello.js with the content: Than type:
  • 6. Design Goals Only a small core library Extensible module system Non blocking I/O As close to system calls as possible
  • 7. Non Blocking I/O First we look at traditional blocking I/O I/O is serialized and the execution time is sum(opA, opB) var a = getSomethingFromDatabase(); c onsole.log(a); v ar b = getSomethingFromDatabase(); console.log(b);
  • 8. Non Blocking I/O getSomethingFromDatabase(paramA, function(result) { console.log(result); }); getSomethingFromDatabase(paramB function(result) { console.log(result); }); Both queries are handled in an event queue and don't block each other Execution time is MAX(op1,op2)
  • 9. Non Blocking I/O node.js uses epoll, kqueue or whatever is available at the underlying operating system So I/O does not waste your CPU cycles No busy waiting! Thread pool is used for everything else
  • 10. (No) Threads The rest of your app is single threaded Easy programming model but is not useful for all kinds of apps
  • 11. Your Webserver in 6 LOC var http = require('http'); http.createServer( function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World\n'); }).listen(8888, "127.0.0.1"); console.log('Server running at http://127.0.0.1:8888/'); Pretty simple, isn't it?
  • 12. Ever needed to poll for filechange? var fs = require('fs'); fs.watchFile(__filename, function() { console.log('I was changed!'); process.exit(0); });
  • 13. So what can I do with node.js node.js is great for all I/O centric tasks Nearly all network apps are I/O centric (web or application server, socket server and so on)
  • 14. node.js is good for... Web applications Streaming Unix tools (yeah, you can start your files with #!/usr/bin/node )
  • 15. Don't use it for... CPU intense apps with few I/O Apps that need huge memory (V8 has a 1.9G limit) Multiple cores need multiple processes (single threaded)
  • 16. Modules you will fall in love with Express Socket.IO Cradle (CouchDB module)
  • 17. There is room for improvement Tool support Debugging Error reporting Windows support (when you realy want a Windows server) XML support
  • 18. JavaScript Support Node JS contains CommonsJS EcmaScript5 Usable node API
  • 19. Integration Great support for NonSQL stores: CouchDB, Redis But you still can use your RDB -> modules for all major databases
  • 20. Resources http://nodejs.org/ https://github.com/joyent/node/wiki/modules http://expressjs.com/ http://socket.io/ You will need a good JavaScript understanding http://oreilly.com/catalog/9780596517748
  • 21. Gerhard Hipfinger openForce Information Technology GesmbH Dresdner Str. 108 / 3. Stock / Top 11 1200 Wien TEL +43 1 3191775 FAX +43 1 3191775-20 http://openforce.com