SlideShare a Scribd company logo
1 of 42
Download to read offline
rd

3 Generation
Web Application Platforms
Naresh Chintalcheru
st

1 Generation
CGI : Common Gateway Interface
CGI Scripting languages
▪CGI C
▪CGI Perl
▪CGI TCL
▪CGI Basic
One Process per User Request
[Operating System Processes, Threads, Semaphores, Mutexes and Barriers,
are the scheduling mechanisms to acquire the time slices of the CPU. The
Processes are expensive and consume more resources than Threads]
Drawbacks:
▪ The CGI script interpretation (compile + execution)
happens at the request processing time.
▪ One user request spawns one Process, locking all the
allocated resources even though request processing
might not need it.
▪ The CGI spawned Process is outside the Web Server
control.
nd

2 Generation
ISAPI Engines
ISAPI : Internet Server Application Programming Interface
2

nd

Generation Platforms

▪ J2EE
▪ .Net
▪ LAMP
▪ Ruby on Rails
▪ Groovy on Grails
What is common in the
2

nd

generation platforms ?
Multi-Threaded Runtime
One Thread per User Request
Image Source
JEE Request-To-Thread
Request 1

Application Server

Thread 1

Spring
DispatcherServlet
Thread 2

Request 2
JSF FacesServlet
Struts ActionServlet

Thread .. n

Request .. n
One Servlet instance on the App Server
spawns a new thread for each user request
Drawbacks:
▪ One thread per user request locks the resources
allocated to the thread at the time (wait) of I/O
operations.
▪ Context-switching between threads are expensive.
rd

3 Generation
Single Thread Runtime
One Thread for [many] Users Request
Image Source
How it is possible one Thread
can serve multiple users ?
▪Lets see how many cycles it
takes for a Disk I/O
Image Source
▪It takes around 41 million cycles to do a
disk I/O.
▪For a network call 240 million cycles ….

“Understanding Node Event-Loop” – Must read excellent blog post from Mixu.
▪Swim into the micro millisecond
world.
▪Everything in the multi-threaded
server is …..
Waiting … Waiting … Waiting … Waiting …

Waiting … Waiting … Waiting … Waiting …

Waiting … Waiting … Waiting … Waiting …

Waiting … Waiting … Waiting … Waiting …

Waiting … Waiting … Waiting … Waiting .

Waiting … Waiting … Waiting … Wait

Waiting…Waiting…Waiting…Wait

Waiting … Waiting
…Wait
▪While the user request is waiting for an
I/O operation, the 3rd generation platforms use
Non-Blocking I/O based call-backs managed by
an Event-Loop and the Thread will move on to
the next request.
▪The whole thing happens so fast that one
Thread will be able to respond to multiple user
requests.
3rd generation platforms

▪Node.js for JavaScript
▪Vert.x for Java
▪Libevent for C
▪Twisted for Python
▪EventMachine for Ruby
3rd generation platforms
The rest of the presentation will focus on

Node.js
Unbelievable Concurrency ?
▪ Assuming each thread has 2 MB of
memory running on 8 GB of RAM puts it at a
theoretical maximum of 4000 concurrent
connections, plus the cost of context-switching
between threads.
▪ That’s the scenario you typically deal with in
traditional web-serving techniques. By avoiding all
that, Node.js achieves scalability levels of over

1Million concurrent connections
(as a proof-of-concept).
The 3rd generation platforms use the
combination below to efficiently utilize the OS
resources.

Single Thread
Non-Blocking I/O
Event Loop
Node.js
▪ Platform based Server-side JavaScript
▪ Event-Driven Concurrency Model
▪ Use single thread and non-blocking I/O
▪ JSON and JavaScript are practically siblings
that translate to Nodes
▪ JavaScript is a dynamically typed language
▪ Real-time web applications employing server-side
push and two-way connections where server and
client can initiate communication
▪ I/O Operations executed in parallel but not the
code
▪So throw-out JEE/.Net applications
and rewrite in node.js ?
Node.js makes it an excellent choice
for I/O based Applications.

What are I/O based Applications?
Applications which connect to databases, make web service calls, use files for logging
and make connections to MQ, Mail & LDAP servers.
Node.js is not a good choice for

CPU intensive Applications.
(Node pundits argue that CPU intensive components should be evented and
passed onto another thread)

What are CPU intensive Applications?
Applications which does lot of data processing on the App server and complex
calculations which need more CPU time.
Node.js itself is not Non-Blocking
function getAge(user_id) {
sql = 'SELECT age FROM users WHERE id = ' + user_id;
connection.query(sql, function(err, rows, fields) {
if (err) throw err;
return rows[0].age;
});
return 0;
}
[The above database call code will starve the thread and node
will not respond to other users]
Below Node.js code will unblock I/O and
respond to other users
function getAge(user_id, callback) {
sql = 'SELECT age FROM users WHERE id = ' + user_id;
connection.query(sql, function(err, rows, fields) {
if (err) throw err;
var age = rows[0].age;
callback(age);
});
}
[The above database call code uses callbacks and unblock
the I/O]
Programming for Node.js requires clear
understanding of:

▪Asynchronous code
▪Event-Driven
▪Non-Blocking I/O
▪Callbacks and Promises
Who is using Node.js ?
Paypal, LinkedIn, eBay,
Yahoo, Walmart ……………
http://nodejs.org/industry/
Node.js does not frameworks ?
Ever growing list of presentation, data
persistence and many more
frameworks ……………
http://nodeframework.com/
With the ever growing cost of hardware, power
to cool them and long maintenance cycles ….
How long will enterprises withstand the
temptation of

rd

3 Generation Platform ?
Disclaimer:
The views and opinions expressed in this article are those of the author.
The metrics and numbers used in this presentation are from the open
blogs which are not validated. This is a technical presentation which
will make you think about the new platform options in the technology.
References:
▪ http://labs.vmware.com/vmtj/autonomous-resource-sharing-for-multithreaded-workloads-in-virtualized-servers
▪ http://adamgent.com/post/10440924094/does-java-have-an-answer-tonode-js
▪ http://www.toptal.com/nodejs/why-the-hell-would-i-use-node-js
▪ http://blog.caustik.com/2012/08/19/node-js-w1m-concurrent-connections/
▪ http://bijoor.me/2013/06/09/java-ee-threads-vs-node-js-which-is-better-forconcurrent-data-processing-operations/
▪ http://www.ibm.com/developerworks/java/library/j-nodejs/index.html
▪ http://www.qnx.com/developers/docs/6.4.1
/neutrino/getting_started/s1_procs.html#More_synchronization
▪ http://zef.me/5390/decoupling-events-vs-dependency-injection
▪ http://highscalability.com/blog/2013/3/18/beyond-threads-and-callbacksapplication-architecture-pros-a.html
▪ http://stackoverflow.com/questions/4296505/understanding-promises-innode-js

More Related Content

What's hot

Modularize JavaScript with RequireJS
Modularize JavaScript with RequireJSModularize JavaScript with RequireJS
Modularize JavaScript with RequireJS
Minh Hoang
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
Mohammad Qureshi
 
Frontend Application Architecture, Patterns, and Workflows
Frontend Application Architecture, Patterns, and WorkflowsFrontend Application Architecture, Patterns, and Workflows
Frontend Application Architecture, Patterns, and Workflows
Treasure Data, Inc.
 

What's hot (20)

React js Demo Explanation
React js Demo ExplanationReact js Demo Explanation
React js Demo Explanation
 
Modularize JavaScript with RequireJS
Modularize JavaScript with RequireJSModularize JavaScript with RequireJS
Modularize JavaScript with RequireJS
 
RequireJS
RequireJSRequireJS
RequireJS
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
 
Node js
Node jsNode js
Node js
 
Frontend Application Architecture, Patterns, and Workflows
Frontend Application Architecture, Patterns, and WorkflowsFrontend Application Architecture, Patterns, and Workflows
Frontend Application Architecture, Patterns, and Workflows
 
Vert.x - Tehran JUG meeting Aug-2014 - Saeed Zarinfam
Vert.x - Tehran JUG meeting Aug-2014 - Saeed ZarinfamVert.x - Tehran JUG meeting Aug-2014 - Saeed Zarinfam
Vert.x - Tehran JUG meeting Aug-2014 - Saeed Zarinfam
 
Rest api with node js and express
Rest api with node js and expressRest api with node js and express
Rest api with node js and express
 
Web Development with AngularJS, NodeJS and ExpressJS
Web Development with AngularJS, NodeJS and ExpressJSWeb Development with AngularJS, NodeJS and ExpressJS
Web Development with AngularJS, NodeJS and ExpressJS
 
Node js crash course session 2
Node js crash course   session 2Node js crash course   session 2
Node js crash course session 2
 
Servlet and JSP
Servlet and JSPServlet and JSP
Servlet and JSP
 
8 Most Effective Node.js Tools for Developers
8 Most Effective Node.js Tools for Developers8 Most Effective Node.js Tools for Developers
8 Most Effective Node.js Tools for Developers
 
An Introduction To Testing In AngularJS Applications
An Introduction To Testing In AngularJS Applications An Introduction To Testing In AngularJS Applications
An Introduction To Testing In AngularJS Applications
 
Best node js course
Best node js courseBest node js course
Best node js course
 
Node, express & sails
Node, express & sailsNode, express & sails
Node, express & sails
 
J servlets
J servletsJ servlets
J servlets
 
Managing JavaScript Dependencies With RequireJS
Managing JavaScript Dependencies With RequireJSManaging JavaScript Dependencies With RequireJS
Managing JavaScript Dependencies With RequireJS
 
Getting started with node JS
Getting started with node JSGetting started with node JS
Getting started with node JS
 
Learning React - I
Learning React - ILearning React - I
Learning React - I
 
Introduction to node.js aka NodeJS
Introduction to node.js aka NodeJSIntroduction to node.js aka NodeJS
Introduction to node.js aka NodeJS
 

Viewers also liked

Viewers also liked (14)

Big Trends in Big Data
Big Trends in Big DataBig Trends in Big Data
Big Trends in Big Data
 
Lie Cheat & Steal to build Hyper-Fast Applications using Event-Driven Archite...
Lie Cheat & Steal to build Hyper-Fast Applications using Event-Driven Archite...Lie Cheat & Steal to build Hyper-Fast Applications using Event-Driven Archite...
Lie Cheat & Steal to build Hyper-Fast Applications using Event-Driven Archite...
 
Object-Oriented Polymorphism Unleashed
Object-Oriented Polymorphism UnleashedObject-Oriented Polymorphism Unleashed
Object-Oriented Polymorphism Unleashed
 
Java7 New Features and Code Examples
Java7 New Features and Code ExamplesJava7 New Features and Code Examples
Java7 New Features and Code Examples
 
Dental adhesives
Dental adhesivesDental adhesives
Dental adhesives
 
Mule ESB Fundamentals
Mule ESB FundamentalsMule ESB Fundamentals
Mule ESB Fundamentals
 
Adhesion in dentistry
Adhesion in dentistryAdhesion in dentistry
Adhesion in dentistry
 
Adhesives
AdhesivesAdhesives
Adhesives
 
05.adhesion and adhesives theory
05.adhesion and adhesives theory05.adhesion and adhesives theory
05.adhesion and adhesives theory
 
Adhesives
AdhesivesAdhesives
Adhesives
 
Adhesives
AdhesivesAdhesives
Adhesives
 
Acid Etching of Enamel and Bond Strength
Acid Etching of Enamel and Bond StrengthAcid Etching of Enamel and Bond Strength
Acid Etching of Enamel and Bond Strength
 
Adhesion in restorative dentistry
Adhesion in restorative dentistryAdhesion in restorative dentistry
Adhesion in restorative dentistry
 
DENTIN BONDING AGENTS
 DENTIN BONDING AGENTS DENTIN BONDING AGENTS
DENTIN BONDING AGENTS
 

Similar to 3rd Generation Web Application Platforms

Node.js Enterprise Middleware
Node.js Enterprise MiddlewareNode.js Enterprise Middleware
Node.js Enterprise Middleware
Behrad Zari
 
WEEK07operatingsystemdepartmentofsoftwareengineering.pptx
WEEK07operatingsystemdepartmentofsoftwareengineering.pptxWEEK07operatingsystemdepartmentofsoftwareengineering.pptx
WEEK07operatingsystemdepartmentofsoftwareengineering.pptx
babayaga920391
 

Similar to 3rd Generation Web Application Platforms (20)

Understanding the Single Thread Event Loop
Understanding the Single Thread Event LoopUnderstanding the Single Thread Event Loop
Understanding the Single Thread Event Loop
 
Node js internal
Node js internalNode js internal
Node js internal
 
Scalability using Node.js
Scalability using Node.jsScalability using Node.js
Scalability using Node.js
 
Introduction to Real Time Java
Introduction to Real Time JavaIntroduction to Real Time Java
Introduction to Real Time Java
 
Introduction to NodeJS
Introduction to NodeJSIntroduction to NodeJS
Introduction to NodeJS
 
Node.js Enterprise Middleware
Node.js Enterprise MiddlewareNode.js Enterprise Middleware
Node.js Enterprise Middleware
 
Introduction to Node.JS
Introduction to Node.JSIntroduction to Node.JS
Introduction to Node.JS
 
18_Node.js.ppt
18_Node.js.ppt18_Node.js.ppt
18_Node.js.ppt
 
Beginners Node.js
Beginners Node.jsBeginners Node.js
Beginners Node.js
 
18_Node.js.ppt
18_Node.js.ppt18_Node.js.ppt
18_Node.js.ppt
 
NodeJS : Communication and Round Robin Way
NodeJS : Communication and Round Robin WayNodeJS : Communication and Round Robin Way
NodeJS : Communication and Round Robin Way
 
Node.js: A Guided Tour
Node.js: A Guided TourNode.js: A Guided Tour
Node.js: A Guided Tour
 
Loom promises: be there!
Loom promises: be there!Loom promises: be there!
Loom promises: be there!
 
Nodejs
NodejsNodejs
Nodejs
 
Intro to Databases
Intro to DatabasesIntro to Databases
Intro to Databases
 
Metarhia: Node.js Macht Frei
Metarhia: Node.js Macht FreiMetarhia: Node.js Macht Frei
Metarhia: Node.js Macht Frei
 
WEEK07operatingsystemdepartmentofsoftwareengineering.pptx
WEEK07operatingsystemdepartmentofsoftwareengineering.pptxWEEK07operatingsystemdepartmentofsoftwareengineering.pptx
WEEK07operatingsystemdepartmentofsoftwareengineering.pptx
 
Evented Ruby VS Node.js
Evented Ruby VS Node.jsEvented Ruby VS Node.js
Evented Ruby VS Node.js
 
Exploring Twitter's Finagle technology stack for microservices
Exploring Twitter's Finagle technology stack for microservicesExploring Twitter's Finagle technology stack for microservices
Exploring Twitter's Finagle technology stack for microservices
 
Node azure
Node azureNode azure
Node azure
 

More from Naresh Chintalcheru (9)

Cars.com Journey to AWS Cloud
Cars.com Journey to AWS CloudCars.com Journey to AWS Cloud
Cars.com Journey to AWS Cloud
 
Bimodal IT for Speed and Innovation
Bimodal IT for Speed and InnovationBimodal IT for Speed and Innovation
Bimodal IT for Speed and Innovation
 
Reactive systems
Reactive systemsReactive systems
Reactive systems
 
Problems opening SOA to the Online Web Applications
Problems opening SOA to the Online Web ApplicationsProblems opening SOA to the Online Web Applications
Problems opening SOA to the Online Web Applications
 
Design & Develop Batch Applications in Java/JEE
Design & Develop Batch Applications in Java/JEEDesign & Develop Batch Applications in Java/JEE
Design & Develop Batch Applications in Java/JEE
 
Building Next Generation Real-Time Web Applications using Websockets
Building Next Generation Real-Time Web Applications using WebsocketsBuilding Next Generation Real-Time Web Applications using Websockets
Building Next Generation Real-Time Web Applications using Websockets
 
Automation Testing using Selenium
Automation Testing using SeleniumAutomation Testing using Selenium
Automation Testing using Selenium
 
Design & Development of Web Applications using SpringMVC
Design & Development of Web Applications using SpringMVC Design & Development of Web Applications using SpringMVC
Design & Development of Web Applications using SpringMVC
 
Android Platform Architecture
Android Platform ArchitectureAndroid Platform Architecture
Android Platform Architecture
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Recently uploaded (20)

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 

3rd Generation Web Application Platforms

  • 1. rd 3 Generation Web Application Platforms Naresh Chintalcheru
  • 3. CGI : Common Gateway Interface
  • 4. CGI Scripting languages ▪CGI C ▪CGI Perl ▪CGI TCL ▪CGI Basic
  • 5. One Process per User Request [Operating System Processes, Threads, Semaphores, Mutexes and Barriers, are the scheduling mechanisms to acquire the time slices of the CPU. The Processes are expensive and consume more resources than Threads]
  • 6. Drawbacks: ▪ The CGI script interpretation (compile + execution) happens at the request processing time. ▪ One user request spawns one Process, locking all the allocated resources even though request processing might not need it. ▪ The CGI spawned Process is outside the Web Server control.
  • 8. ISAPI Engines ISAPI : Internet Server Application Programming Interface
  • 9. 2 nd Generation Platforms ▪ J2EE ▪ .Net ▪ LAMP ▪ Ruby on Rails ▪ Groovy on Grails
  • 10. What is common in the 2 nd generation platforms ?
  • 12. One Thread per User Request
  • 14. JEE Request-To-Thread Request 1 Application Server Thread 1 Spring DispatcherServlet Thread 2 Request 2 JSF FacesServlet Struts ActionServlet Thread .. n Request .. n One Servlet instance on the App Server spawns a new thread for each user request
  • 15. Drawbacks: ▪ One thread per user request locks the resources allocated to the thread at the time (wait) of I/O operations. ▪ Context-switching between threads are expensive.
  • 18. One Thread for [many] Users Request
  • 20. How it is possible one Thread can serve multiple users ?
  • 21. ▪Lets see how many cycles it takes for a Disk I/O
  • 23. ▪It takes around 41 million cycles to do a disk I/O. ▪For a network call 240 million cycles …. “Understanding Node Event-Loop” – Must read excellent blog post from Mixu.
  • 24. ▪Swim into the micro millisecond world. ▪Everything in the multi-threaded server is …..
  • 25. Waiting … Waiting … Waiting … Waiting … Waiting … Waiting … Waiting … Waiting … Waiting … Waiting … Waiting … Waiting … Waiting … Waiting … Waiting … Waiting … Waiting … Waiting … Waiting … Waiting . Waiting … Waiting … Waiting … Wait Waiting…Waiting…Waiting…Wait Waiting … Waiting …Wait
  • 26. ▪While the user request is waiting for an I/O operation, the 3rd generation platforms use Non-Blocking I/O based call-backs managed by an Event-Loop and the Thread will move on to the next request. ▪The whole thing happens so fast that one Thread will be able to respond to multiple user requests.
  • 27. 3rd generation platforms ▪Node.js for JavaScript ▪Vert.x for Java ▪Libevent for C ▪Twisted for Python ▪EventMachine for Ruby
  • 28. 3rd generation platforms The rest of the presentation will focus on Node.js
  • 29. Unbelievable Concurrency ? ▪ Assuming each thread has 2 MB of memory running on 8 GB of RAM puts it at a theoretical maximum of 4000 concurrent connections, plus the cost of context-switching between threads. ▪ That’s the scenario you typically deal with in traditional web-serving techniques. By avoiding all that, Node.js achieves scalability levels of over 1Million concurrent connections (as a proof-of-concept).
  • 30. The 3rd generation platforms use the combination below to efficiently utilize the OS resources. Single Thread Non-Blocking I/O Event Loop
  • 31. Node.js ▪ Platform based Server-side JavaScript ▪ Event-Driven Concurrency Model ▪ Use single thread and non-blocking I/O ▪ JSON and JavaScript are practically siblings that translate to Nodes ▪ JavaScript is a dynamically typed language ▪ Real-time web applications employing server-side push and two-way connections where server and client can initiate communication ▪ I/O Operations executed in parallel but not the code
  • 32. ▪So throw-out JEE/.Net applications and rewrite in node.js ?
  • 33. Node.js makes it an excellent choice for I/O based Applications. What are I/O based Applications? Applications which connect to databases, make web service calls, use files for logging and make connections to MQ, Mail & LDAP servers.
  • 34. Node.js is not a good choice for CPU intensive Applications. (Node pundits argue that CPU intensive components should be evented and passed onto another thread) What are CPU intensive Applications? Applications which does lot of data processing on the App server and complex calculations which need more CPU time.
  • 35. Node.js itself is not Non-Blocking function getAge(user_id) { sql = 'SELECT age FROM users WHERE id = ' + user_id; connection.query(sql, function(err, rows, fields) { if (err) throw err; return rows[0].age; }); return 0; } [The above database call code will starve the thread and node will not respond to other users]
  • 36. Below Node.js code will unblock I/O and respond to other users function getAge(user_id, callback) { sql = 'SELECT age FROM users WHERE id = ' + user_id; connection.query(sql, function(err, rows, fields) { if (err) throw err; var age = rows[0].age; callback(age); }); } [The above database call code uses callbacks and unblock the I/O]
  • 37. Programming for Node.js requires clear understanding of: ▪Asynchronous code ▪Event-Driven ▪Non-Blocking I/O ▪Callbacks and Promises
  • 38. Who is using Node.js ? Paypal, LinkedIn, eBay, Yahoo, Walmart …………… http://nodejs.org/industry/
  • 39. Node.js does not frameworks ? Ever growing list of presentation, data persistence and many more frameworks …………… http://nodeframework.com/
  • 40. With the ever growing cost of hardware, power to cool them and long maintenance cycles …. How long will enterprises withstand the temptation of rd 3 Generation Platform ?
  • 41. Disclaimer: The views and opinions expressed in this article are those of the author. The metrics and numbers used in this presentation are from the open blogs which are not validated. This is a technical presentation which will make you think about the new platform options in the technology.
  • 42. References: ▪ http://labs.vmware.com/vmtj/autonomous-resource-sharing-for-multithreaded-workloads-in-virtualized-servers ▪ http://adamgent.com/post/10440924094/does-java-have-an-answer-tonode-js ▪ http://www.toptal.com/nodejs/why-the-hell-would-i-use-node-js ▪ http://blog.caustik.com/2012/08/19/node-js-w1m-concurrent-connections/ ▪ http://bijoor.me/2013/06/09/java-ee-threads-vs-node-js-which-is-better-forconcurrent-data-processing-operations/ ▪ http://www.ibm.com/developerworks/java/library/j-nodejs/index.html ▪ http://www.qnx.com/developers/docs/6.4.1 /neutrino/getting_started/s1_procs.html#More_synchronization ▪ http://zef.me/5390/decoupling-events-vs-dependency-injection ▪ http://highscalability.com/blog/2013/3/18/beyond-threads-and-callbacksapplication-architecture-pros-a.html ▪ http://stackoverflow.com/questions/4296505/understanding-promises-innode-js