SlideShare ist ein Scribd-Unternehmen logo
1 von 28
Downloaden Sie, um offline zu lesen
Emerging Paradigms - 
Server Side Event Driven 
Programming 
Kamal Hussain 
http://www.linkedin.com/in/hussainkamal/
Agenda 
● Linear Vs Nonlinear Code 
● Concurrency through threads and events 
● Event loop 
● PHP and Javascript 
● Node.js - closeup 
● Important concepts
We are used to .. 
val client = new HttpClient() 
val method = new GetMethod("http: 
//www.google.com") 
val statusCode = client.executeMethod 
(method) 
println("Server responded with %d" . 
format(statusCode))
Event driven approach 
var callback = function(data) { 
console.log("firing callback " + 
data); 
}; 
$.get('/endpoint', callback); 
console.log('Did you see callback?');
Achieving scale and concurrency 
● Multiple threads/processes 
● Size the threadpool correctly 
● Each thread is responsible for one task such 
as serving a request 
● Asynchronous programming
Asynchronous with 
threads/processes
Asynchronous with events
Problems with Threads 
● Hard to program 
● Memory requirements are high 
● Large overhead 
● Context switching 
● Priority inversion
Threads wait 
udemy.com
Cost of IO 
L1 Cache 3 Cycles 
L2 Cache 14 Cycles 
RAM 250 cycles 
Disk 41 000 000 cycles 
Network 240 000 000 cycles
Event Loop Architecture 
courtsey: http://www.johanndutoit.net/
Writing synchronous Vs 
Asynchronous 
// Good: write files asynchronously 
fs.writeFile('message.txt', 'Hello Node', function (err) { 
console.log("It's saved and the server remains responsive!"); 
}); 
// BAD: write files synchronously 
fs.writeFileSync('message.txt', 'Hello Node'); 
console.log("It's saved, but you just blocked ALL requests!"); 
This can cause performance drop from thousands of requests/seconds to a few 
dozen/second. 
http://engineering.linkedin.com/nodejs/blazing-fast-nodejs-10-performance-tips-linkedin- 
mobile
Tale of two languages 
● PHP was invented in 1994 by Rasmus 
Lerdorfas as a replacement for CGI scripts 
● PHP was a substitute for single-threaded C 
programs 
● Brendan Eich developed Javascript in 1995 
for a completely different purpose. JS was 
designed to run within Netscape Navigator 
and was primarily designed to handle 
events. 
PHP -> eventless, Javascript -> eventful
Node.js 
● Ryan Dahl invented Node.js in 2009 as a 
continuation of Javascript heritage. 
● Node.js is modeled after multi-task, multi-page 
handling of a web server.
What's Node.js? 
"Node.js is a server-side software system designed for 
writing scalable Internet applications, notably web servers. 
Programs are written on the server side in JavaScript, 
using event-driven, asynchronous I/O to minimize overhead 
and maximize scalability." 
- from wikipedia
Node.js - asynchronous I/O 
● First class functions 
● Closures 
● Event loop 
● Callback counters 
CPU intensive tasks are delegated to workers
PHP Way 
$fp = fopen("fp.txt", 'w) 
fwrite($fp, "hello world"); 
fclose($fp);
Node.js way 
var fs = require('fs'); 
fs.open('fp.txt', 'w', 0666, 
function(error, fp) { 
fw.write(fp, 'helloworld', null, 
'utf-8', function() { 
fs.close(fp, function(error) { 
}); 
}); 
});
Node.js simple example 
var http = require('http'); 
http.createServer(function(req, res) { 
res.writeHead(200, {'Content-Type' : 
'text/plain'}); 
res.end("Hello Worldn"); 
}).listen(8000, "127.0.0.1"); 
console.log("Server running at http: 
//127.0.0.1:8000");
Node.js Core APIs 
Events 
EventTransmitter 
Event listener 
Event emitter 
Call back 
Http 
I/O
Node.js Workers 
Synchronous call 
Workers are blocked 
Call returns
Workers Vs Events 
Workers 
1 event per connection 
N workers per CPU 
Events 
N connections per CPU 
1 process per CPU
Node.js Typical Applications 
● Proxy 
● API server 
○ REST API calls 
○ Simple transformations 
See performance comparisons at: 
http://www.slideshare.net/FabianFrankDe/nodejs-performance-case-study
Concepts to learn 
First class functions 
Lambdas - anonymous functions 
Closures 
Non-blocking IO
Deploying Node.js 
http://www.slideshare.net/BenLin2/webconf-nodejsproductionarchitecture
Key takeaway 
Learn Javascript and 
functional programming. 
Future is brighter :)
Reference 
● Node - Up and Running by Tom Hughes-Croucher, 
Mike Wilson - Oreilly 
● Node.js for PHP Developers - Oreilly 
● Javascript: The definitive guide - Oreilly 
● LinkedIn, Netflix Blogs 
● http://architects.dzone.com/articles/nodejs-php-programmers- 
1-event 
● https://www.udemy.com/lectures/understanding-the-nodejs- 
event-loop-91298 
● https://speakerdeck.com/guldenpt/before-start-coding-in- 
node-dot-js

Weitere ähnliche Inhalte

Was ist angesagt?

Let’s talk about JavaScript - WebElement
Let’s talk about JavaScript - WebElementLet’s talk about JavaScript - WebElement
Let’s talk about JavaScript - WebElementMarian Rusnak
 
Beautiful code instead of callback hell using ES6 Generators, Koa, Bluebird (...
Beautiful code instead of callback hell using ES6 Generators, Koa, Bluebird (...Beautiful code instead of callback hell using ES6 Generators, Koa, Bluebird (...
Beautiful code instead of callback hell using ES6 Generators, Koa, Bluebird (...andreaslubbe
 
Everything ruby
Everything rubyEverything ruby
Everything rubyajeygore
 
Node.js System: The Approach
Node.js System: The ApproachNode.js System: The Approach
Node.js System: The ApproachHaci Murat Yaman
 
Create Rest API in Nodejs
Create Rest API in Nodejs Create Rest API in Nodejs
Create Rest API in Nodejs Irfan Maulana
 
Event Driven Architecture Concepts in Web Technologies - Part 1
Event Driven Architecture Concepts in Web Technologies - Part 1Event Driven Architecture Concepts in Web Technologies - Part 1
Event Driven Architecture Concepts in Web Technologies - Part 1Hamidreza Soleimani
 
Streams are Awesome - (Node.js) TimesOpen Sep 2012
Streams are Awesome - (Node.js) TimesOpen Sep 2012 Streams are Awesome - (Node.js) TimesOpen Sep 2012
Streams are Awesome - (Node.js) TimesOpen Sep 2012 Tom Croucher
 
Using Node.js to Build Great Streaming Services - HTML5 Dev Conf
Using Node.js to  Build Great  Streaming Services - HTML5 Dev ConfUsing Node.js to  Build Great  Streaming Services - HTML5 Dev Conf
Using Node.js to Build Great Streaming Services - HTML5 Dev ConfTom Croucher
 
Server side JavaScript: going all the way
Server side JavaScript: going all the wayServer side JavaScript: going all the way
Server side JavaScript: going all the wayOleg Podsechin
 
React PHP: the NodeJS challenger
React PHP: the NodeJS challengerReact PHP: the NodeJS challenger
React PHP: the NodeJS challengervanphp
 
Javascript Everywhere From Nose To Tail
Javascript Everywhere From Nose To TailJavascript Everywhere From Nose To Tail
Javascript Everywhere From Nose To TailCliffano Subagio
 
Asynchronous I/O in PHP
Asynchronous I/O in PHPAsynchronous I/O in PHP
Asynchronous I/O in PHPThomas Weinert
 
Node.js: CAMTA Presentation
Node.js: CAMTA PresentationNode.js: CAMTA Presentation
Node.js: CAMTA PresentationRob Tweed
 
Introduction to NodeJS with LOLCats
Introduction to NodeJS with LOLCatsIntroduction to NodeJS with LOLCats
Introduction to NodeJS with LOLCatsDerek Anderson
 
20170310 PHP goal pyramid for memorising
20170310 PHP goal pyramid for memorising20170310 PHP goal pyramid for memorising
20170310 PHP goal pyramid for memorisingSharon Liu
 
Securing Prometheus exporters using HashiCorp Vault
Securing Prometheus exporters using HashiCorp VaultSecuring Prometheus exporters using HashiCorp Vault
Securing Prometheus exporters using HashiCorp VaultBram Vogelaar
 
Shell Scripting-training-course-navi-mumbai-shell-scripting-course-provider-n...
Shell Scripting-training-course-navi-mumbai-shell-scripting-course-provider-n...Shell Scripting-training-course-navi-mumbai-shell-scripting-course-provider-n...
Shell Scripting-training-course-navi-mumbai-shell-scripting-course-provider-n...VibrantGroup
 

Was ist angesagt? (20)

Let’s talk about JavaScript - WebElement
Let’s talk about JavaScript - WebElementLet’s talk about JavaScript - WebElement
Let’s talk about JavaScript - WebElement
 
Beautiful code instead of callback hell using ES6 Generators, Koa, Bluebird (...
Beautiful code instead of callback hell using ES6 Generators, Koa, Bluebird (...Beautiful code instead of callback hell using ES6 Generators, Koa, Bluebird (...
Beautiful code instead of callback hell using ES6 Generators, Koa, Bluebird (...
 
Everything ruby
Everything rubyEverything ruby
Everything ruby
 
Node.js System: The Approach
Node.js System: The ApproachNode.js System: The Approach
Node.js System: The Approach
 
Create Rest API in Nodejs
Create Rest API in Nodejs Create Rest API in Nodejs
Create Rest API in Nodejs
 
Node.js concurrency
Node.js concurrencyNode.js concurrency
Node.js concurrency
 
Event Driven Architecture Concepts in Web Technologies - Part 1
Event Driven Architecture Concepts in Web Technologies - Part 1Event Driven Architecture Concepts in Web Technologies - Part 1
Event Driven Architecture Concepts in Web Technologies - Part 1
 
Streams are Awesome - (Node.js) TimesOpen Sep 2012
Streams are Awesome - (Node.js) TimesOpen Sep 2012 Streams are Awesome - (Node.js) TimesOpen Sep 2012
Streams are Awesome - (Node.js) TimesOpen Sep 2012
 
Using Node.js to Build Great Streaming Services - HTML5 Dev Conf
Using Node.js to  Build Great  Streaming Services - HTML5 Dev ConfUsing Node.js to  Build Great  Streaming Services - HTML5 Dev Conf
Using Node.js to Build Great Streaming Services - HTML5 Dev Conf
 
Server side JavaScript: going all the way
Server side JavaScript: going all the wayServer side JavaScript: going all the way
Server side JavaScript: going all the way
 
React PHP: the NodeJS challenger
React PHP: the NodeJS challengerReact PHP: the NodeJS challenger
React PHP: the NodeJS challenger
 
Javascript Everywhere From Nose To Tail
Javascript Everywhere From Nose To TailJavascript Everywhere From Nose To Tail
Javascript Everywhere From Nose To Tail
 
Asynchronous I/O in PHP
Asynchronous I/O in PHPAsynchronous I/O in PHP
Asynchronous I/O in PHP
 
Node.js: CAMTA Presentation
Node.js: CAMTA PresentationNode.js: CAMTA Presentation
Node.js: CAMTA Presentation
 
Introduction to NodeJS with LOLCats
Introduction to NodeJS with LOLCatsIntroduction to NodeJS with LOLCats
Introduction to NodeJS with LOLCats
 
20170310 PHP goal pyramid for memorising
20170310 PHP goal pyramid for memorising20170310 PHP goal pyramid for memorising
20170310 PHP goal pyramid for memorising
 
Securing Prometheus exporters using HashiCorp Vault
Securing Prometheus exporters using HashiCorp VaultSecuring Prometheus exporters using HashiCorp Vault
Securing Prometheus exporters using HashiCorp Vault
 
Shell Scripting & Ruby Hacking
Shell Scripting & Ruby HackingShell Scripting & Ruby Hacking
Shell Scripting & Ruby Hacking
 
Node.js
Node.jsNode.js
Node.js
 
Shell Scripting-training-course-navi-mumbai-shell-scripting-course-provider-n...
Shell Scripting-training-course-navi-mumbai-shell-scripting-course-provider-n...Shell Scripting-training-course-navi-mumbai-shell-scripting-course-provider-n...
Shell Scripting-training-course-navi-mumbai-shell-scripting-course-provider-n...
 

Andere mochten auch

Contentspagefeedback
ContentspagefeedbackContentspagefeedback
Contentspagefeedbackjaritluin
 
Silabus Eksponensial dan Logaritma
Silabus Eksponensial dan LogaritmaSilabus Eksponensial dan Logaritma
Silabus Eksponensial dan LogaritmaTrya Wulanabi
 
analisis
analisisanalisis
analisiscahya17
 
Media reader profile
Media reader profileMedia reader profile
Media reader profilejaritluin
 
Materi ajar eksponensial
Materi ajar eksponensialMateri ajar eksponensial
Materi ajar eksponensialTrya Wulanabi
 
A Way Back to You
A Way Back to YouA Way Back to You
A Way Back to Youbellmarie
 
Hyderabad traithlon presentation
Hyderabad traithlon presentationHyderabad traithlon presentation
Hyderabad traithlon presentationRavi Chandra
 
Rpp eksponen.tugas tik dlm tp
Rpp eksponen.tugas tik dlm tpRpp eksponen.tugas tik dlm tp
Rpp eksponen.tugas tik dlm tpTrya Wulanabi
 
Materi ajar eksponensial
Materi ajar eksponensialMateri ajar eksponensial
Materi ajar eksponensialTrya Wulanabi
 
Bab 1 bentuk pangkat, akar & logaritma
Bab 1 bentuk pangkat, akar & logaritmaBab 1 bentuk pangkat, akar & logaritma
Bab 1 bentuk pangkat, akar & logaritmaTrya Wulanabi
 
Bab 1 pertumbuhan dan perkembangan tumbuhan
Bab 1 pertumbuhan dan perkembangan tumbuhanBab 1 pertumbuhan dan perkembangan tumbuhan
Bab 1 pertumbuhan dan perkembangan tumbuhanTrya Wulanabi
 
Silabus biologi pratiwi jilid 3
Silabus biologi pratiwi jilid 3Silabus biologi pratiwi jilid 3
Silabus biologi pratiwi jilid 3Trya Wulanabi
 

Andere mochten auch (18)

Contentspagefeedback
ContentspagefeedbackContentspagefeedback
Contentspagefeedback
 
Silabus Eksponensial dan Logaritma
Silabus Eksponensial dan LogaritmaSilabus Eksponensial dan Logaritma
Silabus Eksponensial dan Logaritma
 
analisis
analisisanalisis
analisis
 
Media reader profile
Media reader profileMedia reader profile
Media reader profile
 
Senza nome 1
Senza nome 1Senza nome 1
Senza nome 1
 
Materi ajar eksponensial
Materi ajar eksponensialMateri ajar eksponensial
Materi ajar eksponensial
 
A Way Back to You
A Way Back to YouA Way Back to You
A Way Back to You
 
Hyderabad traithlon presentation
Hyderabad traithlon presentationHyderabad traithlon presentation
Hyderabad traithlon presentation
 
Rpp eksponen.tugas tik dlm tp
Rpp eksponen.tugas tik dlm tpRpp eksponen.tugas tik dlm tp
Rpp eksponen.tugas tik dlm tp
 
Journal-RISS2015
Journal-RISS2015Journal-RISS2015
Journal-RISS2015
 
Latihan soal
Latihan soalLatihan soal
Latihan soal
 
Materi ajar eksponensial
Materi ajar eksponensialMateri ajar eksponensial
Materi ajar eksponensial
 
Silabus eksponen
Silabus eksponenSilabus eksponen
Silabus eksponen
 
Bab 1 bentuk pangkat, akar & logaritma
Bab 1 bentuk pangkat, akar & logaritmaBab 1 bentuk pangkat, akar & logaritma
Bab 1 bentuk pangkat, akar & logaritma
 
Materi blog
Materi blogMateri blog
Materi blog
 
Bab 1 pertumbuhan dan perkembangan tumbuhan
Bab 1 pertumbuhan dan perkembangan tumbuhanBab 1 pertumbuhan dan perkembangan tumbuhan
Bab 1 pertumbuhan dan perkembangan tumbuhan
 
Rpp blog
Rpp blogRpp blog
Rpp blog
 
Silabus biologi pratiwi jilid 3
Silabus biologi pratiwi jilid 3Silabus biologi pratiwi jilid 3
Silabus biologi pratiwi jilid 3
 

Ähnlich wie Event driven programming -- Node.JS

Server Side Event Driven Programming
Server Side Event Driven ProgrammingServer Side Event Driven Programming
Server Side Event Driven ProgrammingKamal Hussain
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applicationsTom Croucher
 
Introduction to Node.js Platform
Introduction to Node.js PlatformIntroduction to Node.js Platform
Introduction to Node.js PlatformNaresh Chintalcheru
 
Node js introduction
Node js introductionNode js introduction
Node js introductionAlex Su
 
Node.js Workshop - Sela SDP 2015
Node.js Workshop  - Sela SDP 2015Node.js Workshop  - Sela SDP 2015
Node.js Workshop - Sela SDP 2015Nir Noy
 
Node js
Node jsNode js
Node jshazzaz
 
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
 
A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...Tom Croucher
 
Node.js for Rubists
Node.js for RubistsNode.js for Rubists
Node.js for RubistsSagiv Ofek
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1Mohammad Qureshi
 
nodejs_at_a_glance.ppt
nodejs_at_a_glance.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.pptWalaSidhom1
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsVikash Singh
 
Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS drupalcampest
 

Ähnlich wie Event driven programming -- Node.JS (20)

Server Side Event Driven Programming
Server Side Event Driven ProgrammingServer Side Event Driven Programming
Server Side Event Driven Programming
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
 
NodeJS
NodeJSNodeJS
NodeJS
 
Node.js
Node.jsNode.js
Node.js
 
Introduction to Node.js Platform
Introduction to Node.js PlatformIntroduction to Node.js Platform
Introduction to Node.js Platform
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
 
Node.js Workshop - Sela SDP 2015
Node.js Workshop  - Sela SDP 2015Node.js Workshop  - Sela SDP 2015
Node.js Workshop - Sela SDP 2015
 
Node js beginner
Node js beginnerNode js beginner
Node js beginner
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
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
 
A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...
 
Intro to Node
Intro to NodeIntro to Node
Intro to Node
 
Node.js for Rubists
Node.js for RubistsNode.js for Rubists
Node.js for Rubists
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
 
nodejs_at_a_glance.ppt
nodejs_at_a_glance.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.ppt
 
NodeJS
NodeJSNodeJS
NodeJS
 
Node.js 1, 2, 3
Node.js 1, 2, 3Node.js 1, 2, 3
Node.js 1, 2, 3
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS
 

Kürzlich hochgeladen

Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...Call Girls in Nagpur High Profile
 
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl ServiceRussian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl Servicegwenoracqe6
 
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.soniya singh
 
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.CarlotaBedoya1
 
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...Delhi Call girls
 
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call GirlVIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girladitipandeya
 
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...APNIC
 
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445ruhi
 
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.soniya singh
 
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceDelhi Call girls
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...tanu pandey
 
Networking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGNetworking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGAPNIC
 
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝soniya singh
 

Kürzlich hochgeladen (20)

Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
 
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
 
Russian Call Girls in %(+971524965298 )# Call Girls in Dubai
Russian Call Girls in %(+971524965298  )#  Call Girls in DubaiRussian Call Girls in %(+971524965298  )#  Call Girls in Dubai
Russian Call Girls in %(+971524965298 )# Call Girls in Dubai
 
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl ServiceRussian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
 
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
 
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.
 
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
 
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
 
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call GirlVIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
 
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
 
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
 
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
 
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
 
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
 
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
 
Networking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGNetworking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOG
 
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
 

Event driven programming -- Node.JS

  • 1. Emerging Paradigms - Server Side Event Driven Programming Kamal Hussain http://www.linkedin.com/in/hussainkamal/
  • 2. Agenda ● Linear Vs Nonlinear Code ● Concurrency through threads and events ● Event loop ● PHP and Javascript ● Node.js - closeup ● Important concepts
  • 3. We are used to .. val client = new HttpClient() val method = new GetMethod("http: //www.google.com") val statusCode = client.executeMethod (method) println("Server responded with %d" . format(statusCode))
  • 4. Event driven approach var callback = function(data) { console.log("firing callback " + data); }; $.get('/endpoint', callback); console.log('Did you see callback?');
  • 5. Achieving scale and concurrency ● Multiple threads/processes ● Size the threadpool correctly ● Each thread is responsible for one task such as serving a request ● Asynchronous programming
  • 8. Problems with Threads ● Hard to program ● Memory requirements are high ● Large overhead ● Context switching ● Priority inversion
  • 10. Cost of IO L1 Cache 3 Cycles L2 Cache 14 Cycles RAM 250 cycles Disk 41 000 000 cycles Network 240 000 000 cycles
  • 11.
  • 12. Event Loop Architecture courtsey: http://www.johanndutoit.net/
  • 13. Writing synchronous Vs Asynchronous // Good: write files asynchronously fs.writeFile('message.txt', 'Hello Node', function (err) { console.log("It's saved and the server remains responsive!"); }); // BAD: write files synchronously fs.writeFileSync('message.txt', 'Hello Node'); console.log("It's saved, but you just blocked ALL requests!"); This can cause performance drop from thousands of requests/seconds to a few dozen/second. http://engineering.linkedin.com/nodejs/blazing-fast-nodejs-10-performance-tips-linkedin- mobile
  • 14. Tale of two languages ● PHP was invented in 1994 by Rasmus Lerdorfas as a replacement for CGI scripts ● PHP was a substitute for single-threaded C programs ● Brendan Eich developed Javascript in 1995 for a completely different purpose. JS was designed to run within Netscape Navigator and was primarily designed to handle events. PHP -> eventless, Javascript -> eventful
  • 15. Node.js ● Ryan Dahl invented Node.js in 2009 as a continuation of Javascript heritage. ● Node.js is modeled after multi-task, multi-page handling of a web server.
  • 16. What's Node.js? "Node.js is a server-side software system designed for writing scalable Internet applications, notably web servers. Programs are written on the server side in JavaScript, using event-driven, asynchronous I/O to minimize overhead and maximize scalability." - from wikipedia
  • 17. Node.js - asynchronous I/O ● First class functions ● Closures ● Event loop ● Callback counters CPU intensive tasks are delegated to workers
  • 18. PHP Way $fp = fopen("fp.txt", 'w) fwrite($fp, "hello world"); fclose($fp);
  • 19. Node.js way var fs = require('fs'); fs.open('fp.txt', 'w', 0666, function(error, fp) { fw.write(fp, 'helloworld', null, 'utf-8', function() { fs.close(fp, function(error) { }); }); });
  • 20. Node.js simple example var http = require('http'); http.createServer(function(req, res) { res.writeHead(200, {'Content-Type' : 'text/plain'}); res.end("Hello Worldn"); }).listen(8000, "127.0.0.1"); console.log("Server running at http: //127.0.0.1:8000");
  • 21. Node.js Core APIs Events EventTransmitter Event listener Event emitter Call back Http I/O
  • 22. Node.js Workers Synchronous call Workers are blocked Call returns
  • 23. Workers Vs Events Workers 1 event per connection N workers per CPU Events N connections per CPU 1 process per CPU
  • 24. Node.js Typical Applications ● Proxy ● API server ○ REST API calls ○ Simple transformations See performance comparisons at: http://www.slideshare.net/FabianFrankDe/nodejs-performance-case-study
  • 25. Concepts to learn First class functions Lambdas - anonymous functions Closures Non-blocking IO
  • 27. Key takeaway Learn Javascript and functional programming. Future is brighter :)
  • 28. Reference ● Node - Up and Running by Tom Hughes-Croucher, Mike Wilson - Oreilly ● Node.js for PHP Developers - Oreilly ● Javascript: The definitive guide - Oreilly ● LinkedIn, Netflix Blogs ● http://architects.dzone.com/articles/nodejs-php-programmers- 1-event ● https://www.udemy.com/lectures/understanding-the-nodejs- event-loop-91298 ● https://speakerdeck.com/guldenpt/before-start-coding-in- node-dot-js