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

Micro Front-End & Microservices - Plansoft
Micro Front-End & Microservices - PlansoftMicro Front-End & Microservices - Plansoft
Micro Front-End & Microservices - PlansoftMiki Lombardi
 
The State of Ceph, Manila, and Containers in OpenStack
The State of Ceph, Manila, and Containers in OpenStackThe State of Ceph, Manila, and Containers in OpenStack
The State of Ceph, Manila, and Containers in OpenStackSage Weil
 
Vert.x Event Driven Non Blocking Reactive Toolkit
Vert.x Event Driven Non Blocking Reactive ToolkitVert.x Event Driven Non Blocking Reactive Toolkit
Vert.x Event Driven Non Blocking Reactive ToolkitBrian S. Paskin
 
Asynchronous Processing with Outbox Pattern in .NET Core 3.0
Asynchronous Processing with Outbox Pattern in .NET Core 3.0Asynchronous Processing with Outbox Pattern in .NET Core 3.0
Asynchronous Processing with Outbox Pattern in .NET Core 3.0Baris Ceviz
 
Microservices Part 3 Service Mesh and Kafka
Microservices Part 3 Service Mesh and KafkaMicroservices Part 3 Service Mesh and Kafka
Microservices Part 3 Service Mesh and KafkaAraf Karsh Hamid
 
ARCHITECTURE MICROSERVICE : TOUR D’HORIZON DU CONCEPT ET BONNES PRATIQUES
ARCHITECTURE MICROSERVICE : TOUR D’HORIZON DU CONCEPT ET BONNES PRATIQUESARCHITECTURE MICROSERVICE : TOUR D’HORIZON DU CONCEPT ET BONNES PRATIQUES
ARCHITECTURE MICROSERVICE : TOUR D’HORIZON DU CONCEPT ET BONNES PRATIQUESSOAT
 
Grokking TechTalk #31: Asynchronous Communications
Grokking TechTalk #31: Asynchronous CommunicationsGrokking TechTalk #31: Asynchronous Communications
Grokking TechTalk #31: Asynchronous CommunicationsGrokking VN
 
SR-IOV+KVM on Debian/Stable
SR-IOV+KVM on Debian/StableSR-IOV+KVM on Debian/Stable
SR-IOV+KVM on Debian/Stablejuet-y
 
Microservices Docker Kubernetes Istio Kanban DevOps SRE
Microservices Docker Kubernetes Istio Kanban DevOps SREMicroservices Docker Kubernetes Istio Kanban DevOps SRE
Microservices Docker Kubernetes Istio Kanban DevOps SREAraf Karsh Hamid
 
Let’s unbox Rancher 2.0 <v2.0.0>
Let’s unbox Rancher 2.0 <v2.0.0>  Let’s unbox Rancher 2.0 <v2.0.0>
Let’s unbox Rancher 2.0 <v2.0.0> LINE Corporation
 
Service Mesh - Observability
Service Mesh - ObservabilityService Mesh - Observability
Service Mesh - ObservabilityAraf Karsh Hamid
 
Collabnix Online Webinar - Demystifying Docker & Kubernetes Networking by Bal...
Collabnix Online Webinar - Demystifying Docker & Kubernetes Networking by Bal...Collabnix Online Webinar - Demystifying Docker & Kubernetes Networking by Bal...
Collabnix Online Webinar - Demystifying Docker & Kubernetes Networking by Bal...Ajeet Singh Raina
 
Architecture microservices avec docker
Architecture microservices avec dockerArchitecture microservices avec docker
Architecture microservices avec dockergcatt
 
kubernetes를 부탁해~ Prometheus 기반 Monitoring 구축&활용기
kubernetes를 부탁해~ Prometheus 기반 Monitoring 구축&활용기kubernetes를 부탁해~ Prometheus 기반 Monitoring 구축&활용기
kubernetes를 부탁해~ Prometheus 기반 Monitoring 구축&활용기Jinsu Moon
 
Microservices Architecture Part 2 Event Sourcing and Saga
Microservices Architecture Part 2 Event Sourcing and SagaMicroservices Architecture Part 2 Event Sourcing and Saga
Microservices Architecture Part 2 Event Sourcing and SagaAraf Karsh Hamid
 
Microservices, Containers, Kubernetes, Kafka, Kanban
Microservices, Containers, Kubernetes, Kafka, KanbanMicroservices, Containers, Kubernetes, Kafka, Kanban
Microservices, Containers, Kubernetes, Kafka, KanbanAraf Karsh Hamid
 
Enterprise container platform verrazzano
Enterprise container platform verrazzanoEnterprise container platform verrazzano
Enterprise container platform verrazzanoMichel Schildmeijer
 
CQRS and Event Sourcing
CQRS and Event Sourcing CQRS and Event Sourcing
CQRS and Event Sourcing Inho Kang
 
MariaDB MaxScale
MariaDB MaxScaleMariaDB MaxScale
MariaDB MaxScaleMariaDB plc
 

What's hot (20)

Micro Front-End & Microservices - Plansoft
Micro Front-End & Microservices - PlansoftMicro Front-End & Microservices - Plansoft
Micro Front-End & Microservices - Plansoft
 
The State of Ceph, Manila, and Containers in OpenStack
The State of Ceph, Manila, and Containers in OpenStackThe State of Ceph, Manila, and Containers in OpenStack
The State of Ceph, Manila, and Containers in OpenStack
 
Vert.x Event Driven Non Blocking Reactive Toolkit
Vert.x Event Driven Non Blocking Reactive ToolkitVert.x Event Driven Non Blocking Reactive Toolkit
Vert.x Event Driven Non Blocking Reactive Toolkit
 
Asynchronous Processing with Outbox Pattern in .NET Core 3.0
Asynchronous Processing with Outbox Pattern in .NET Core 3.0Asynchronous Processing with Outbox Pattern in .NET Core 3.0
Asynchronous Processing with Outbox Pattern in .NET Core 3.0
 
Microservices Part 3 Service Mesh and Kafka
Microservices Part 3 Service Mesh and KafkaMicroservices Part 3 Service Mesh and Kafka
Microservices Part 3 Service Mesh and Kafka
 
ARCHITECTURE MICROSERVICE : TOUR D’HORIZON DU CONCEPT ET BONNES PRATIQUES
ARCHITECTURE MICROSERVICE : TOUR D’HORIZON DU CONCEPT ET BONNES PRATIQUESARCHITECTURE MICROSERVICE : TOUR D’HORIZON DU CONCEPT ET BONNES PRATIQUES
ARCHITECTURE MICROSERVICE : TOUR D’HORIZON DU CONCEPT ET BONNES PRATIQUES
 
Grokking TechTalk #31: Asynchronous Communications
Grokking TechTalk #31: Asynchronous CommunicationsGrokking TechTalk #31: Asynchronous Communications
Grokking TechTalk #31: Asynchronous Communications
 
SR-IOV+KVM on Debian/Stable
SR-IOV+KVM on Debian/StableSR-IOV+KVM on Debian/Stable
SR-IOV+KVM on Debian/Stable
 
Microservices Docker Kubernetes Istio Kanban DevOps SRE
Microservices Docker Kubernetes Istio Kanban DevOps SREMicroservices Docker Kubernetes Istio Kanban DevOps SRE
Microservices Docker Kubernetes Istio Kanban DevOps SRE
 
Let’s unbox Rancher 2.0 <v2.0.0>
Let’s unbox Rancher 2.0 <v2.0.0>  Let’s unbox Rancher 2.0 <v2.0.0>
Let’s unbox Rancher 2.0 <v2.0.0>
 
Service Mesh - Observability
Service Mesh - ObservabilityService Mesh - Observability
Service Mesh - Observability
 
Collabnix Online Webinar - Demystifying Docker & Kubernetes Networking by Bal...
Collabnix Online Webinar - Demystifying Docker & Kubernetes Networking by Bal...Collabnix Online Webinar - Demystifying Docker & Kubernetes Networking by Bal...
Collabnix Online Webinar - Demystifying Docker & Kubernetes Networking by Bal...
 
Architecture microservices avec docker
Architecture microservices avec dockerArchitecture microservices avec docker
Architecture microservices avec docker
 
Présentation Docker
Présentation DockerPrésentation Docker
Présentation Docker
 
kubernetes를 부탁해~ Prometheus 기반 Monitoring 구축&활용기
kubernetes를 부탁해~ Prometheus 기반 Monitoring 구축&활용기kubernetes를 부탁해~ Prometheus 기반 Monitoring 구축&활용기
kubernetes를 부탁해~ Prometheus 기반 Monitoring 구축&활용기
 
Microservices Architecture Part 2 Event Sourcing and Saga
Microservices Architecture Part 2 Event Sourcing and SagaMicroservices Architecture Part 2 Event Sourcing and Saga
Microservices Architecture Part 2 Event Sourcing and Saga
 
Microservices, Containers, Kubernetes, Kafka, Kanban
Microservices, Containers, Kubernetes, Kafka, KanbanMicroservices, Containers, Kubernetes, Kafka, Kanban
Microservices, Containers, Kubernetes, Kafka, Kanban
 
Enterprise container platform verrazzano
Enterprise container platform verrazzanoEnterprise container platform verrazzano
Enterprise container platform verrazzano
 
CQRS and Event Sourcing
CQRS and Event Sourcing CQRS and Event Sourcing
CQRS and Event Sourcing
 
MariaDB MaxScale
MariaDB MaxScaleMariaDB MaxScale
MariaDB MaxScale
 

Similar to vert.x - asynchronous event-driven web applications 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 vert.x - asynchronous event-driven web applications 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

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 

Recently uploaded (20)

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 

vert.x - asynchronous event-driven web applications 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&amp;blockingsiege -c100 -b -r100 &quot;http://localhost:8080/my-webapp/demo?blocking”DEMO 2siege -c100 -b -r100 &quot;http://localhost:8081/?longrunning&quot;
  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&apos;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.-&gt; This fits the cloud model
  11. Event basierteprogrammier-model schlägvolldurch. KeineAbstraktion!Reading &amp; 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 &amp; Enterprise Übergang z vertx
  13. 15’
  14. Web-Server non blockingsiege -c100 -b -r100 &quot;http://localhost:8081/?longrunning&quot; 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