SlideShare a Scribd company logo
1 of 39
asynchronous event-driven web-
    applications on the JVM
      SBB Developer Day 2012

           Jonas Bandi
         CompuGroup Medical

                                            @jbandi
                               jonas.bandi@gmail.com
Agenda
• Background / Motivation
• Vert.x Platform
• Demos
The Evolution of the Web
Static      Form-driven    AJAX-driven
Pages       applications   applications
Static        Form-driven    AJAX-driven     Real-time
Pages         applications   applications   applications




         http://www.mmoasteroids.com/
The Real Time Web
http://wordsquared.com/
www.cloud9ide.com
The C10k Problem
    It's time for web servers to handle ten
  thousand clients simultaneously, don't you
  think? After all, the web is a big place now.
                                                    (Dan Kegel, 2003)

"Real-time will become the default. It won't be
  this newfangled tech that only Google and
  Facebook and Twitter can afford to build.”
                                                 (ArsTechnica, 2012)
                                      http://en.wikipedia.org/wiki/C10k_problem
                                                 http://www.kegel.com/c10k.htm
     http://arstechnica.com/business/2012/05/say-hello-to-the-real-real-time-web
Connection


Client
         Request 1   Request 2       Request 3



          Thread 1    Thread 2        Thread 1



Server
Waiting …
 route                                               process               format
request                                              results              response




                       query db or                             Write to
                       web service                             log file

Scaling:




Problems: Context Switching, Stack Memory, Concurrency
Demo
(Tomcat blocking on 100 concurrent
      longrunning requests)

siege -c100 -b -r100 "http://localhost:8080/my-webapp/demo?blocking"
Addressing the Problem
• event-driven / asynchronous architecture
   – Many long lived connections are a feature of modern
     applications
   – OS threads are a precious resource
   – Blocked OS threads are bad!

• => Service many connections with a small number of
  threads
• Reactor Pattern (Douglas C. Schmidt, 1995)
   – Event Loop
• different programming model
  => on which abstraction?

                               http://en.wikipedia.org/wiki/Reactor_pattern
Different Programming Model

Clients
                                        delegate long    Workers
                                        running jobs
                                            & IO
                          Event Loop
                             (single
            request       thread, non
                           blocking)
                                              callback




               response
Scaling
Threads:




 Problems: Context Switching, Stack Memory, Concurrency


Event Loop:




                                   Async IO APIs (OS)
Established Solutions
• Nginx
• Jetty                       Infrastructure
• Apache AWF

• EventMachine (Ruby)
                              Application
• Tornado, Twisted (Python)   Frameworks
• Node.js (JavaScript)
Success of Node
• Written in JavaScript, based on V8
• Huge community & ecosystem

• DIRTy Applications: Data Intensive Real Time
• Mostly IO
• Shuffling data from one pipe to another
Meet
Demo
   (vert.x not blocking on 100
concurrent longrunning requests)
    siege -c100 -b -r100 "http://localhost:8081/?longrunning"
What is vert.x?
• General purpose application platform on the JVM
• Provides primarily asynchronous APIs
• Polyglot: Java, JavaScript/CoffeeScript, Groovy,
  Ruby, Python
• Simple but not Simplistic
• Popular for “modern” web applications
• Similarities with Node.js & Akka
• New approach to problems traditionally served
  by classic application servers
The Vert.x Project
•   Open-source (on Github, ASL 2.0)
•   Age: ~1.5 years
•   Sponsor: VMWare
•   Based on: Netty, Hazelcast, SockJS



                     sockjs

                                         Rhino
Core APIs
• TCP/SSL clients and servers
• HTTP/HTTPS clients and servers
  – including WebSockets
• Event bus
• File system
• 100% asynchronous
Verticle 3
                                Background Workers




                                                     Verticle 3
                                                     Verticle 3
Architecture




                                                     Verticle 3
                                                     Verticle 3
               Vertx Instance




                                                                           Event Bus
                                                                  Module




                                                                                       JVM
                                                     Verticle 2
                                                     Verticle 2
                                Event Loop

                                                     Verticle 2
                                                     Verticle 1
                                                     Verticle 1
Scaling
•   Scale by creating more Verticle instances
•   Use message passing to communicate
•   Fine-tune “pools” of verticles
•   For TCP and HTTP servers Vert.x does
    automatic load-balancing
Event Loops are no Silver Bullet
• Don’t block the event loop!
• Long running calculations
• Blocking APIs (i.e. JDBC)
• Most traditional Java libraries have blocking
  APIs
• => Hybrid Threading Model
    – Worker Verticles can block
    – Communication by message passing (Event Bus)
    – Leverage ecosystem of Java libraries
Concurrency Model
• A verticle instance is always single-threaded
• Very different approach from “Java-Style”
  multi-threaded concurrency
  – No more synchronized, volatile or locking
  – Avoid many classic race conditions
Event Bus Demo
                        Vertx Instance

           Event Loop                       Background Workers




                                       Worker

                                                Worker

                                                         Worker

                                                                  Worker

                                                                           Worker
Server

         Server




                           Event Bus



                             JVM
Distributed Event Bus
• Connect multiple Vert.x JVM instances
• Applications are loosely coupled components
  distributed across the network

• Event bus extends to client side JavaScript
• Use the same API on the client
• Distributed event space spans client and server
  nodes
• Ideal for modern “real-time” web applications
Distributed Event Bus Demo

Vertx Instance                                  Vertx Instance
                    Telnet
Event Loop                               Event Loop       Workers
                              Browser
   (JavaScript)




                                          WebSocket
   TCP Server




                                           HTTP &



                                                            Worker

                                                                     Worker
                                           Server
                             Event Bus


    JVM                                               JVM
Web Application Demo
                      Vertx Instance

                 Module          Module      Module
Browser

                  vertx.         vertx.       vertx.
                web-server      aut-mgr      mongo-      Mongo DB
                                             persistor




(WebSocket)                      Event Bus


                                   JVM
The Future
• Scala & Closure support
• Management, including GUI console
• Developer experience – IDE integration,
  testing
• Promises API?
• Direct-style API using continuations?
Summary
 • Polyglot – use the language(s) you want
 • Simple concurrency – wave goodbye to most race
   conditions
 • Leverage existing Java library ecosystem
 • Powerful distributed event bus which spans client
   and server
 • Powerful module system

Vert.x is the platform for a new generation of polyglot web
                 and enterprise applications.
Vert.x vs. Node.JS

          Polyglot    vs.   JavaScript
              JVM     vs.   V8
huge ecosystem of           big ecosystem of
                      vs.
     Java libraries         node modules
 small community      vs.   big community
The big picture
• Alternative approaches (Java):
  – Servlet 3.0
  – NIO connections
Who is using it?




     game-gorilla.com




                         gvmtool.net



 Helsinki Trip Planner
Would I use it now?

• Maybe -> where the distributed architecture
  really fits
• Might get interesting in the future…

• I don’t buy the polyglot story…
• I don’t fully buy the concurrency story …
Discussions?

More Related Content

What's hot

Design patterns for microservice architecture
Design patterns for microservice architectureDesign patterns for microservice architecture
Design patterns for microservice architectureThe Software House
 
Azure kubernetes service (aks)
Azure kubernetes service (aks)Azure kubernetes service (aks)
Azure kubernetes service (aks)Akash Agrawal
 
Next.js Introduction
Next.js IntroductionNext.js Introduction
Next.js IntroductionSaray Chak
 
An Authentication and Authorization Architecture for a Microservices World
An Authentication and Authorization Architecture for a Microservices WorldAn Authentication and Authorization Architecture for a Microservices World
An Authentication and Authorization Architecture for a Microservices WorldVMware Tanzu
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven DesignRyan Riley
 
Principles of Monitoring Microservices
Principles of Monitoring MicroservicesPrinciples of Monitoring Microservices
Principles of Monitoring MicroservicesMichael Ducy
 
Stability Patterns for Microservices
Stability Patterns for MicroservicesStability Patterns for Microservices
Stability Patterns for Microservicespflueras
 
LMAX Disruptor - High Performance Inter-Thread Messaging Library
LMAX Disruptor - High Performance Inter-Thread Messaging LibraryLMAX Disruptor - High Performance Inter-Thread Messaging Library
LMAX Disruptor - High Performance Inter-Thread Messaging LibrarySebastian Andrasoni
 
Concurrent Programming Using the Disruptor
Concurrent Programming Using the DisruptorConcurrent Programming Using the Disruptor
Concurrent Programming Using the DisruptorTrisha Gee
 
Microservices Architecture & Testing Strategies
Microservices Architecture & Testing StrategiesMicroservices Architecture & Testing Strategies
Microservices Architecture & Testing StrategiesAraf Karsh Hamid
 

What's hot (20)

Design patterns for microservice architecture
Design patterns for microservice architectureDesign patterns for microservice architecture
Design patterns for microservice architecture
 
Azure kubernetes service (aks)
Azure kubernetes service (aks)Azure kubernetes service (aks)
Azure kubernetes service (aks)
 
Vertx
VertxVertx
Vertx
 
React workshop
React workshopReact workshop
React workshop
 
Next.js Introduction
Next.js IntroductionNext.js Introduction
Next.js Introduction
 
An Authentication and Authorization Architecture for a Microservices World
An Authentication and Authorization Architecture for a Microservices WorldAn Authentication and Authorization Architecture for a Microservices World
An Authentication and Authorization Architecture for a Microservices World
 
.Net Core
.Net Core.Net Core
.Net Core
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Microservices
MicroservicesMicroservices
Microservices
 
Introduction to Microservices
Introduction to MicroservicesIntroduction to Microservices
Introduction to Microservices
 
Principles of Monitoring Microservices
Principles of Monitoring MicroservicesPrinciples of Monitoring Microservices
Principles of Monitoring Microservices
 
Stability Patterns for Microservices
Stability Patterns for MicroservicesStability Patterns for Microservices
Stability Patterns for Microservices
 
LMAX Disruptor - High Performance Inter-Thread Messaging Library
LMAX Disruptor - High Performance Inter-Thread Messaging LibraryLMAX Disruptor - High Performance Inter-Thread Messaging Library
LMAX Disruptor - High Performance Inter-Thread Messaging Library
 
Concurrent Programming Using the Disruptor
Concurrent Programming Using the DisruptorConcurrent Programming Using the Disruptor
Concurrent Programming Using the Disruptor
 
Distributed fun with etcd
Distributed fun with etcdDistributed fun with etcd
Distributed fun with etcd
 
Microservices Architecture & Testing Strategies
Microservices Architecture & Testing StrategiesMicroservices Architecture & Testing Strategies
Microservices Architecture & Testing Strategies
 
Architecture: Microservices
Architecture: MicroservicesArchitecture: Microservices
Architecture: Microservices
 
Vertx
VertxVertx
Vertx
 
The WebKit project
The WebKit projectThe WebKit project
The WebKit project
 
Microservice architecture
Microservice architectureMicroservice architecture
Microservice architecture
 

Similar to Asynchronous Event-Driven Web Apps on the JVM

Windows Azure Interoperability
Windows Azure InteroperabilityWindows Azure Interoperability
Windows Azure InteroperabilityMihai Dan Nadas
 
Groovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentationGroovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentationStuart (Pid) Williams
 
Comet with node.js and V8
Comet with node.js and V8Comet with node.js and V8
Comet with node.js and V8amix3k
 
Is OSGi modularity always worth it?
Is OSGi modularity always worth it?Is OSGi modularity always worth it?
Is OSGi modularity always worth it?glynnormington
 
Vert.x introduction
Vert.x introductionVert.x introduction
Vert.x introductionGR8Conf
 
Server Side JavaScript on the Java Platform - David Delabassee
Server Side JavaScript on the Java Platform - David DelabasseeServer Side JavaScript on the Java Platform - David Delabassee
Server Side JavaScript on the Java Platform - David DelabasseeJAXLondon2014
 
Xebia Knowledge Exchange (feb 2011) - Large Scale Web Development
Xebia Knowledge Exchange (feb 2011) - Large Scale Web DevelopmentXebia Knowledge Exchange (feb 2011) - Large Scale Web Development
Xebia Knowledge Exchange (feb 2011) - Large Scale Web DevelopmentMichaël Figuière
 
Build Java Web Application Using Apache Struts
Build Java Web Application Using Apache Struts Build Java Web Application Using Apache Struts
Build Java Web Application Using Apache Struts weili_at_slideshare
 
Genomic Computation at Scale with Serverless, StackStorm and Docker Swarm
Genomic Computation at Scale with Serverless, StackStorm and Docker SwarmGenomic Computation at Scale with Serverless, StackStorm and Docker Swarm
Genomic Computation at Scale with Serverless, StackStorm and Docker SwarmDmitri Zimine
 
Evented Ruby VS Node.js
Evented Ruby VS Node.jsEvented Ruby VS Node.js
Evented Ruby VS Node.jsNitin Gupta
 
Kann JavaScript elegant sein?
Kann JavaScript elegant sein?Kann JavaScript elegant sein?
Kann JavaScript elegant sein?jbandi
 
Node.js meetup at Palo Alto Networks Tel Aviv
Node.js meetup at Palo Alto Networks Tel AvivNode.js meetup at Palo Alto Networks Tel Aviv
Node.js meetup at Palo Alto Networks Tel AvivRon Perlmuter
 
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
 

Similar to Asynchronous Event-Driven Web Apps on the JVM (20)

Windows Azure Interoperability
Windows Azure InteroperabilityWindows Azure Interoperability
Windows Azure Interoperability
 
Groovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentationGroovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentation
 
Comet with node.js and V8
Comet with node.js and V8Comet with node.js and V8
Comet with node.js and V8
 
Is OSGi modularity always worth it?
Is OSGi modularity always worth it?Is OSGi modularity always worth it?
Is OSGi modularity always worth it?
 
Vert.x introduction
Vert.x introductionVert.x introduction
Vert.x introduction
 
Introducing spring
Introducing springIntroducing spring
Introducing spring
 
Server Side JavaScript on the Java Platform - David Delabassee
Server Side JavaScript on the Java Platform - David DelabasseeServer Side JavaScript on the Java Platform - David Delabassee
Server Side JavaScript on the Java Platform - David Delabassee
 
Xebia Knowledge Exchange (feb 2011) - Large Scale Web Development
Xebia Knowledge Exchange (feb 2011) - Large Scale Web DevelopmentXebia Knowledge Exchange (feb 2011) - Large Scale Web Development
Xebia Knowledge Exchange (feb 2011) - Large Scale Web Development
 
Vert.x devoxx london 2013
Vert.x devoxx london 2013Vert.x devoxx london 2013
Vert.x devoxx london 2013
 
Node js internal
Node js internalNode js internal
Node js internal
 
Build Java Web Application Using Apache Struts
Build Java Web Application Using Apache Struts Build Java Web Application Using Apache Struts
Build Java Web Application Using Apache Struts
 
Scala and Lift
Scala and LiftScala and Lift
Scala and Lift
 
Genomic Computation at Scale with Serverless, StackStorm and Docker Swarm
Genomic Computation at Scale with Serverless, StackStorm and Docker SwarmGenomic Computation at Scale with Serverless, StackStorm and Docker Swarm
Genomic Computation at Scale with Serverless, StackStorm and Docker Swarm
 
Asif
AsifAsif
Asif
 
Evented Ruby VS Node.js
Evented Ruby VS Node.jsEvented Ruby VS Node.js
Evented Ruby VS Node.js
 
Kann JavaScript elegant sein?
Kann JavaScript elegant sein?Kann JavaScript elegant sein?
Kann JavaScript elegant sein?
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVC
 
Node.js meetup at Palo Alto Networks Tel Aviv
Node.js meetup at Palo Alto Networks Tel AvivNode.js meetup at Palo Alto Networks Tel Aviv
Node.js meetup at Palo Alto Networks Tel Aviv
 
Vertx Basics
Vertx BasicsVertx Basics
Vertx Basics
 
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
 

More from jbandi

From User Action to Framework Reaction
From User Action to Framework ReactionFrom User Action to Framework Reaction
From User Action to Framework Reactionjbandi
 
From User Action to Framework Reaction
From User Action to Framework ReactionFrom User Action to Framework Reaction
From User Action to Framework Reactionjbandi
 
Angular 2: What's New?
Angular 2: What's New?Angular 2: What's New?
Angular 2: What's New?jbandi
 
The curious Life of JavaScript - Talk at SI-SE 2015
The curious Life of JavaScript - Talk at SI-SE 2015The curious Life of JavaScript - Talk at SI-SE 2015
The curious Life of JavaScript - Talk at SI-SE 2015jbandi
 
Java & JavaScript: Best Friends?
Java & JavaScript: Best Friends?Java & JavaScript: Best Friends?
Java & JavaScript: Best Friends?jbandi
 
There is something about JavaScript - Choose Forum 2014
There is something about JavaScript - Choose Forum 2014There is something about JavaScript - Choose Forum 2014
There is something about JavaScript - Choose Forum 2014jbandi
 
Professional JavaScript Development (An Introduction for Java Developers)
Professional JavaScript Development (An Introduction for Java Developers)Professional JavaScript Development (An Introduction for Java Developers)
Professional JavaScript Development (An Introduction for Java Developers)jbandi
 
NDC 2011 - Building .NET Applications with BDD
NDC 2011 - Building .NET Applications with BDDNDC 2011 - Building .NET Applications with BDD
NDC 2011 - Building .NET Applications with BDDjbandi
 
NDC 2011 - SpecFlow: Pragmatic BDD for .NET
NDC 2011 - SpecFlow: Pragmatic BDD for .NETNDC 2011 - SpecFlow: Pragmatic BDD for .NET
NDC 2011 - SpecFlow: Pragmatic BDD for .NETjbandi
 
Testing Heute: ein Relikt aus dem Zeitalter des goldenen Wasserfalls?
Testing Heute: ein Relikt aus dem Zeitalter des goldenen Wasserfalls?Testing Heute: ein Relikt aus dem Zeitalter des goldenen Wasserfalls?
Testing Heute: ein Relikt aus dem Zeitalter des goldenen Wasserfalls?jbandi
 
Testing: Chances and Challenges in an agile World
Testing: Chances and Challenges in an agile WorldTesting: Chances and Challenges in an agile World
Testing: Chances and Challenges in an agile Worldjbandi
 

More from jbandi (11)

From User Action to Framework Reaction
From User Action to Framework ReactionFrom User Action to Framework Reaction
From User Action to Framework Reaction
 
From User Action to Framework Reaction
From User Action to Framework ReactionFrom User Action to Framework Reaction
From User Action to Framework Reaction
 
Angular 2: What's New?
Angular 2: What's New?Angular 2: What's New?
Angular 2: What's New?
 
The curious Life of JavaScript - Talk at SI-SE 2015
The curious Life of JavaScript - Talk at SI-SE 2015The curious Life of JavaScript - Talk at SI-SE 2015
The curious Life of JavaScript - Talk at SI-SE 2015
 
Java & JavaScript: Best Friends?
Java & JavaScript: Best Friends?Java & JavaScript: Best Friends?
Java & JavaScript: Best Friends?
 
There is something about JavaScript - Choose Forum 2014
There is something about JavaScript - Choose Forum 2014There is something about JavaScript - Choose Forum 2014
There is something about JavaScript - Choose Forum 2014
 
Professional JavaScript Development (An Introduction for Java Developers)
Professional JavaScript Development (An Introduction for Java Developers)Professional JavaScript Development (An Introduction for Java Developers)
Professional JavaScript Development (An Introduction for Java Developers)
 
NDC 2011 - Building .NET Applications with BDD
NDC 2011 - Building .NET Applications with BDDNDC 2011 - Building .NET Applications with BDD
NDC 2011 - Building .NET Applications with BDD
 
NDC 2011 - SpecFlow: Pragmatic BDD for .NET
NDC 2011 - SpecFlow: Pragmatic BDD for .NETNDC 2011 - SpecFlow: Pragmatic BDD for .NET
NDC 2011 - SpecFlow: Pragmatic BDD for .NET
 
Testing Heute: ein Relikt aus dem Zeitalter des goldenen Wasserfalls?
Testing Heute: ein Relikt aus dem Zeitalter des goldenen Wasserfalls?Testing Heute: ein Relikt aus dem Zeitalter des goldenen Wasserfalls?
Testing Heute: ein Relikt aus dem Zeitalter des goldenen Wasserfalls?
 
Testing: Chances and Challenges in an agile World
Testing: Chances and Challenges in an agile WorldTesting: Chances and Challenges in an agile World
Testing: Chances and Challenges in an agile World
 

Recently uploaded

Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 

Recently uploaded (20)

Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 

Asynchronous Event-Driven Web Apps on the JVM

  • 1. asynchronous event-driven web- applications on the JVM SBB Developer Day 2012 Jonas Bandi CompuGroup Medical @jbandi jonas.bandi@gmail.com
  • 2. Agenda • Background / Motivation • Vert.x Platform • Demos
  • 3. The Evolution of the Web Static Form-driven AJAX-driven Pages applications applications
  • 4. Static Form-driven AJAX-driven Real-time Pages applications applications applications http://www.mmoasteroids.com/
  • 8. The C10k Problem It's time for web servers to handle ten thousand clients simultaneously, don't you think? After all, the web is a big place now. (Dan Kegel, 2003) "Real-time will become the default. It won't be this newfangled tech that only Google and Facebook and Twitter can afford to build.” (ArsTechnica, 2012) http://en.wikipedia.org/wiki/C10k_problem http://www.kegel.com/c10k.htm http://arstechnica.com/business/2012/05/say-hello-to-the-real-real-time-web
  • 9. Connection Client Request 1 Request 2 Request 3 Thread 1 Thread 2 Thread 1 Server
  • 10. Waiting … route process format request results response query db or Write to web service log file Scaling: Problems: Context Switching, Stack Memory, Concurrency
  • 11. Demo (Tomcat blocking on 100 concurrent longrunning requests) siege -c100 -b -r100 "http://localhost:8080/my-webapp/demo?blocking"
  • 12. Addressing the Problem • event-driven / asynchronous architecture – Many long lived connections are a feature of modern applications – OS threads are a precious resource – Blocked OS threads are bad! • => Service many connections with a small number of threads • Reactor Pattern (Douglas C. Schmidt, 1995) – Event Loop • different programming model => on which abstraction? http://en.wikipedia.org/wiki/Reactor_pattern
  • 13. Different Programming Model Clients delegate long Workers running jobs & IO Event Loop (single request thread, non blocking) callback response
  • 14. Scaling Threads: Problems: Context Switching, Stack Memory, Concurrency Event Loop: Async IO APIs (OS)
  • 15. Established Solutions • Nginx • Jetty Infrastructure • Apache AWF • EventMachine (Ruby) Application • Tornado, Twisted (Python) Frameworks • Node.js (JavaScript)
  • 16.
  • 17.
  • 18.
  • 19. Success of Node • Written in JavaScript, based on V8 • Huge community & ecosystem • DIRTy Applications: Data Intensive Real Time • Mostly IO • Shuffling data from one pipe to another
  • 20. Meet
  • 21. Demo (vert.x not blocking on 100 concurrent longrunning requests) siege -c100 -b -r100 "http://localhost:8081/?longrunning"
  • 22. What is vert.x? • General purpose application platform on the JVM • Provides primarily asynchronous APIs • Polyglot: Java, JavaScript/CoffeeScript, Groovy, Ruby, Python • Simple but not Simplistic • Popular for “modern” web applications • Similarities with Node.js & Akka • New approach to problems traditionally served by classic application servers
  • 23. The Vert.x Project • Open-source (on Github, ASL 2.0) • Age: ~1.5 years • Sponsor: VMWare • Based on: Netty, Hazelcast, SockJS sockjs Rhino
  • 24. Core APIs • TCP/SSL clients and servers • HTTP/HTTPS clients and servers – including WebSockets • Event bus • File system • 100% asynchronous
  • 25. Verticle 3 Background Workers Verticle 3 Verticle 3 Architecture Verticle 3 Verticle 3 Vertx Instance Event Bus Module JVM Verticle 2 Verticle 2 Event Loop Verticle 2 Verticle 1 Verticle 1
  • 26. Scaling • Scale by creating more Verticle instances • Use message passing to communicate • Fine-tune “pools” of verticles • For TCP and HTTP servers Vert.x does automatic load-balancing
  • 27. Event Loops are no Silver Bullet • Don’t block the event loop! • Long running calculations • Blocking APIs (i.e. JDBC) • Most traditional Java libraries have blocking APIs • => Hybrid Threading Model – Worker Verticles can block – Communication by message passing (Event Bus) – Leverage ecosystem of Java libraries
  • 28. Concurrency Model • A verticle instance is always single-threaded • Very different approach from “Java-Style” multi-threaded concurrency – No more synchronized, volatile or locking – Avoid many classic race conditions
  • 29. Event Bus Demo Vertx Instance Event Loop Background Workers Worker Worker Worker Worker Worker Server Server Event Bus JVM
  • 30. Distributed Event Bus • Connect multiple Vert.x JVM instances • Applications are loosely coupled components distributed across the network • Event bus extends to client side JavaScript • Use the same API on the client • Distributed event space spans client and server nodes • Ideal for modern “real-time” web applications
  • 31. Distributed Event Bus Demo Vertx Instance Vertx Instance Telnet Event Loop Event Loop Workers Browser (JavaScript) WebSocket TCP Server HTTP & Worker Worker Server Event Bus JVM JVM
  • 32. Web Application Demo Vertx Instance Module Module Module Browser vertx. vertx. vertx. web-server aut-mgr mongo- Mongo DB persistor (WebSocket) Event Bus JVM
  • 33. The Future • Scala & Closure support • Management, including GUI console • Developer experience – IDE integration, testing • Promises API? • Direct-style API using continuations?
  • 34. Summary • Polyglot – use the language(s) you want • Simple concurrency – wave goodbye to most race conditions • Leverage existing Java library ecosystem • Powerful distributed event bus which spans client and server • Powerful module system Vert.x is the platform for a new generation of polyglot web and enterprise applications.
  • 35. Vert.x vs. Node.JS Polyglot vs. JavaScript JVM vs. V8 huge ecosystem of big ecosystem of vs. Java libraries node modules small community vs. big community
  • 36. The big picture • Alternative approaches (Java): – Servlet 3.0 – NIO connections
  • 37. Who is using it? game-gorilla.com gvmtool.net Helsinki Trip Planner
  • 38. Would I use it now? • Maybe -> where the distributed architecture really fits • Might get interesting in the future… • I don’t buy the polyglot story… • I don’t fully buy the concurrency story …

Editor's Notes

  1. http://www.mmoasteroids.comhttp://wordsquared.com/https://npmjs.org/https://github.com/popular/starredVertx module repositoryDEMO 1http://localhost:8080/my-webapp/demohttp://localhost:8080/my-webapp/demo?n=45&blockingsiege -c100 -b -r100 "http://localhost:8080/my-webapp/demo?blocking”DEMO 2siege -c100 -b -r100 "http://localhost:8081/?longrunning"
  2. First WWW page: August 1991XMLHTTP Request: 1996 (iframe, asynchronous content loading)AJAX as a term: 2005XMLHttpRequest spec by W3C in 2006
  3. Google TalkVs. Real Time Computing- Receiver not known / ensuredpush vs. pullusers receive information when publishedno need for active requiring informationthick clients in the browserdata is exchanged, not finished web page
  4. Herausforderung an unsere Internet-InfrastrukturVielmehrlanglebigeconnecctions connection / peristente connectionsMobile und grundsätzlicheVernetzungInternet of ThingsEs hat sichgezeigt, dass 10’000 connections so eine “magisce” Grenzeist, die eszuknackengibt.
  5. This can involve a combination of operating system constraints and web server software limitations.While there are some specialized web servers that can handle more than ten thousand client connections, most web servers currently handle at most ten thousand clients simultaneously.http://stackoverflow.com/questions/763579/how-many-threads-can-a-java-vm-supportSo under 32-bit Windows, for example, where each process has a user address space of 2GB, giving each thread a 128K stack size, you'd expect an absolute maximum of 16384 threads (=2*1024*1024 / 128). In practice, I find I can start up about 13,000 under XP.
  6. Long running requestsBlocking threads
  7. In a lot of typical server applications threads are mostly waiting on IO.
  8. Reactor Pattern: 1995threads are one of the bottlenecks for scaling
  9. ÜberleitungzuNode.jsTwisted: Apple Calendar, NASA, Twilio …Node: LinkedIn, Walmart, Microsoft, Yammer, Browserling.MS: Azure Mobile Services uses Node in the Backend http://www.windowsazure.com/en-us/develop/mobile/
  10. Node is simple. The learning-curve is not steep (if you accept JavaScript)Node embraces JavaScript (Devs, JSON, Browser-Platforms, Mobile)JavaScript is Event-Driven, non-blocking and single-threaded in the Client Node mixes runtime platform with application framework.-> This fits the cloud model
  11. Event basierteprogrammier-model schlägvolldurch. KeineAbstraktion!Reading & Debugging (vs. sequential code)
  12. JavaScript:Huge amount of Web-DevelopersJavaScript fits Event-Based Architecture (Single threaded Event-Loop in Browser), existing concepts and libraries can be reusedEvent-Based API is known by those developersSimple, easy to learnPerformant und skalierteinigermassenNode jumped into the space of real-time web applications. Mostly PHP Devs … on the edge of Web & Enterprise Übergang z vertx
  13. 15’
  14. Web-Server non blockingsiege -c100 -b -r100 "http://localhost:8081/?longrunning" Running_ From IDE, from commandline
  15. Not really a framework, rather comparable with Tomcat or Jetty than with JSF or EJB
  16. Verticles have their own classloaderMessages are passed by value
  17. DEMO: Blocking WebServer
  18. Most new functionality should be provided as modules
  19. DEMO: Instances
  20. BlockingScalingMessage Passing
  21. 30’Event bus enables easy creation of real-time web applicationsMobile applications, gamesClint side library very small, can be used with any JS libraries
  22. Distributed System very easy, same programming concepts
  23. Building abstractionsAllowing long lived connections on a higher abstraction level than event-based APIs.
  24. Loosely coupled Microservices
  25. Vs. Real Time Computing- Receiver not known / ensured