SlideShare une entreprise Scribd logo
1  sur  14
Télécharger pour lire hors ligne
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
● ...

Contenu connexe

Tendances

Use Node.js to create a REST API
Use Node.js to create a REST APIUse Node.js to create a REST API
Use Node.js to create a REST APIFabien Vauchelles
 
Socket programming, and openresty
Socket programming, and openrestySocket programming, and openresty
Socket programming, and openrestyTavish Naruka
 
Fundamental of Node.JS - Internship Presentation - Week7
Fundamental of Node.JS - Internship Presentation - Week7Fundamental of Node.JS - Internship Presentation - Week7
Fundamental of Node.JS - Internship Presentation - Week7Devang Garach
 
Meetup RomaJS - introduzione interattiva a Node.js - Luca Lanziani - Codemoti...
Meetup RomaJS - introduzione interattiva a Node.js - Luca Lanziani - Codemoti...Meetup RomaJS - introduzione interattiva a Node.js - Luca Lanziani - Codemoti...
Meetup RomaJS - introduzione interattiva a Node.js - Luca Lanziani - Codemoti...Codemotion
 
My journey from PHP to Node.js
My journey from PHP to Node.jsMy journey from PHP to Node.js
My journey from PHP to Node.jsValentin Lup
 
Introduction to REST API with Node.js
Introduction to REST API with Node.jsIntroduction to REST API with Node.js
Introduction to REST API with Node.jsYoann Gotthilf
 
IT Operations for Web Developers
IT Operations for Web DevelopersIT Operations for Web Developers
IT Operations for Web DevelopersMahmoud Said
 
Node.js tutoria for beginner
Node.js tutoria for beginnerNode.js tutoria for beginner
Node.js tutoria for beginnerManinder Singh
 
3 Things Everyone Knows About Node JS That You Don't
3 Things Everyone Knows About Node JS That You Don't3 Things Everyone Knows About Node JS That You Don't
3 Things Everyone Knows About Node JS That You Don'tF5 Buddy
 
Jugando con websockets en nodeJS
Jugando con websockets en nodeJSJugando con websockets en nodeJS
Jugando con websockets en nodeJSIsrael Gutiérrez
 
Basics of Node.js
Basics of Node.jsBasics of Node.js
Basics of Node.jsAlper Unal
 

Tendances (20)

Use Node.js to create a REST API
Use Node.js to create a REST APIUse Node.js to create a REST API
Use Node.js to create a REST API
 
Socket programming, and openresty
Socket programming, and openrestySocket programming, and openresty
Socket programming, and openresty
 
Fundamental of Node.JS - Internship Presentation - Week7
Fundamental of Node.JS - Internship Presentation - Week7Fundamental of Node.JS - Internship Presentation - Week7
Fundamental of Node.JS - Internship Presentation - Week7
 
Future of NodeJS
Future of NodeJSFuture of NodeJS
Future of NodeJS
 
node.js dao
node.js daonode.js dao
node.js dao
 
Meetup RomaJS - introduzione interattiva a Node.js - Luca Lanziani - Codemoti...
Meetup RomaJS - introduzione interattiva a Node.js - Luca Lanziani - Codemoti...Meetup RomaJS - introduzione interattiva a Node.js - Luca Lanziani - Codemoti...
Meetup RomaJS - introduzione interattiva a Node.js - Luca Lanziani - Codemoti...
 
My journey from PHP to Node.js
My journey from PHP to Node.jsMy journey from PHP to Node.js
My journey from PHP to Node.js
 
Node.js concurrency
Node.js concurrencyNode.js concurrency
Node.js concurrency
 
Introduction to REST API with Node.js
Introduction to REST API with Node.jsIntroduction to REST API with Node.js
Introduction to REST API with Node.js
 
IT Operations for Web Developers
IT Operations for Web DevelopersIT Operations for Web Developers
IT Operations for Web Developers
 
Nodejs
NodejsNodejs
Nodejs
 
(C)NodeJS
(C)NodeJS(C)NodeJS
(C)NodeJS
 
Node.js tutoria for beginner
Node.js tutoria for beginnerNode.js tutoria for beginner
Node.js tutoria for beginner
 
3 Things Everyone Knows About Node JS That You Don't
3 Things Everyone Knows About Node JS That You Don't3 Things Everyone Knows About Node JS That You Don't
3 Things Everyone Knows About Node JS That You Don't
 
NodeJS
NodeJSNodeJS
NodeJS
 
Ferrara Linux Day 2011
Ferrara Linux Day 2011Ferrara Linux Day 2011
Ferrara Linux Day 2011
 
WebSockets with PHP: Mission impossible
WebSockets with PHP: Mission impossibleWebSockets with PHP: Mission impossible
WebSockets with PHP: Mission impossible
 
Jugando con websockets en nodeJS
Jugando con websockets en nodeJSJugando con websockets en nodeJS
Jugando con websockets en nodeJS
 
Node js first look - 2016
Node js first look - 2016Node js first look - 2016
Node js first look - 2016
 
Basics of Node.js
Basics of Node.jsBasics of Node.js
Basics of Node.js
 

En vedette

Node js quick-tour_v2
Node js quick-tour_v2Node js quick-tour_v2
Node js quick-tour_v2tianyi5212222
 
Node js presentation
Node js presentationNode js presentation
Node js presentationmartincabrera
 
Node.js ― Hello, world! の1歩先へ。
Node.js ― Hello, world! の1歩先へ。Node.js ― Hello, world! の1歩先へ。
Node.js ― Hello, world! の1歩先へ。Tatsuya Tobioka
 
Modern UI Development With Node.js
Modern UI Development With Node.jsModern UI Development With Node.js
Modern UI Development With Node.jsRyan Anklam
 

En vedette (6)

Node js quick-tour_v2
Node js quick-tour_v2Node js quick-tour_v2
Node js quick-tour_v2
 
About Node.js
About Node.jsAbout Node.js
About Node.js
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Node js presentation
Node js presentationNode js presentation
Node js presentation
 
Node.js ― Hello, world! の1歩先へ。
Node.js ― Hello, world! の1歩先へ。Node.js ― Hello, world! の1歩先へ。
Node.js ― Hello, world! の1歩先へ。
 
Modern UI Development With Node.js
Modern UI Development With Node.jsModern UI Development With Node.js
Modern UI Development With Node.js
 

Similaire à 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 talkAarti Parikh
 
Cape Cod Web Technology Meetup - 2
Cape Cod Web Technology Meetup - 2Cape Cod Web Technology Meetup - 2
Cape Cod Web Technology Meetup - 2Asher Martin
 
Node.js for Rubists
Node.js for RubistsNode.js for Rubists
Node.js for RubistsSagiv Ofek
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch
 
Node.js - async for the rest of us.
Node.js - async for the rest of us.Node.js - async for the rest of us.
Node.js - async for the rest of us.Mike Brevoort
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.jsorkaplan
 
An overview of node.js
An overview of node.jsAn overview of node.js
An overview of node.jsvaluebound
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsVikash Singh
 
Node js introduction
Node js introductionNode js introduction
Node js introductionAlex Su
 
Introduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.comIntroduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.comVan-Duyet Le
 
New Jersey Red Hat Users Group Presentation: Provisioning anywhere
New Jersey Red Hat Users Group Presentation: Provisioning anywhereNew Jersey Red Hat Users Group Presentation: Provisioning anywhere
New Jersey Red Hat Users Group Presentation: Provisioning anywhereRodrique Heron
 
Nodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredevNodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredevFelix Geisendörfer
 
Introduction to WAMP, a protocol enabling PUB/SUB and RPC over Websocket
Introduction to WAMP, a protocol enabling PUB/SUB and RPC over WebsocketIntroduction to WAMP, a protocol enabling PUB/SUB and RPC over Websocket
Introduction to WAMP, a protocol enabling PUB/SUB and RPC over Websocketsametmax
 
Построение простого 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
 

Similaire à Node.js (20)

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
 
Event driven programming -- Node.JS
Event driven programming -- Node.JSEvent driven programming -- Node.JS
Event driven programming -- Node.JS
 
Cape Cod Web Technology Meetup - 2
Cape Cod Web Technology Meetup - 2Cape Cod Web Technology Meetup - 2
Cape Cod Web Technology Meetup - 2
 
Node.js for Rubists
Node.js for RubistsNode.js for Rubists
Node.js for Rubists
 
Nodejs
NodejsNodejs
Nodejs
 
NodeJS for Beginner
NodeJS for BeginnerNodeJS for Beginner
NodeJS for Beginner
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.js
 
Node.js - async for the rest of us.
Node.js - async for the rest of us.Node.js - async for the rest of us.
Node.js - async for the rest of us.
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
An overview of node.js
An overview of node.jsAn overview of node.js
An overview of node.js
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
 
Introduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.comIntroduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.com
 
Proposal
ProposalProposal
Proposal
 
New Jersey Red Hat Users Group Presentation: Provisioning anywhere
New Jersey Red Hat Users Group Presentation: Provisioning anywhereNew Jersey Red Hat Users Group Presentation: Provisioning anywhere
New Jersey Red Hat Users Group Presentation: Provisioning anywhere
 
Nodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredevNodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredev
 
Node js beginner
Node js beginnerNode js beginner
Node js beginner
 
Introduction to WAMP, a protocol enabling PUB/SUB and RPC over Websocket
Introduction to WAMP, a protocol enabling PUB/SUB and RPC over WebsocketIntroduction to WAMP, a protocol enabling PUB/SUB and RPC over Websocket
Introduction to WAMP, a protocol enabling PUB/SUB and RPC over Websocket
 
Построение простого 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
 
NodeJS
NodeJSNodeJS
NodeJS
 

Plus de EU Edge

Synchronization with CouchDB and PouchDB
Synchronization with CouchDB and PouchDBSynchronization with CouchDB and PouchDB
Synchronization with CouchDB and PouchDBEU Edge
 
How I learned to Stop Worrying and Love the inline-block
How I learned to Stop Worrying and Love the inline-blockHow I learned to Stop Worrying and Love the inline-block
How I learned to Stop Worrying and Love the inline-blockEU Edge
 
What is python
What is pythonWhat is python
What is pythonEU Edge
 
Advanced python
Advanced pythonAdvanced python
Advanced pythonEU Edge
 
Python alapu mobil backend
Python alapu mobil backendPython alapu mobil backend
Python alapu mobil backendEU Edge
 
Res tful services
Res tful servicesRes tful services
Res tful servicesEU Edge
 
Google glass a developers perspective
Google glass   a developers perspectiveGoogle glass   a developers perspective
Google glass a developers perspectiveEU Edge
 
Google glass ict day presentation
Google glass   ict day presentationGoogle glass   ict day presentation
Google glass ict day presentationEU Edge
 
How does it work the keyboard
How does it work   the keyboardHow does it work   the keyboard
How does it work the keyboardEU Edge
 
Node webkit-meetup
Node webkit-meetupNode webkit-meetup
Node webkit-meetupEU Edge
 
Frontend meetup 2014.06.25
Frontend meetup 2014.06.25Frontend meetup 2014.06.25
Frontend meetup 2014.06.25EU Edge
 
Eu edge intro
Eu edge introEu edge intro
Eu edge introEU Edge
 
Halado css eu edge
Halado css   eu edgeHalado css   eu edge
Halado css eu edgeEU Edge
 
Miért jó oktatóanyagot készíteni?
Miért jó oktatóanyagot készíteni?Miért jó oktatóanyagot készíteni?
Miért jó oktatóanyagot készíteni?EU Edge
 

Plus de EU Edge (16)

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

Dernier

Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 

Dernier (20)

Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 

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 ● ...