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

CQRS and Event Sourcing
CQRS and Event Sourcing CQRS and Event Sourcing
CQRS and Event Sourcing Inho Kang
 
Nuxt.js et les applications isomorphiques (Universelles/SSR)
Nuxt.js et les applications isomorphiques (Universelles/SSR)Nuxt.js et les applications isomorphiques (Universelles/SSR)
Nuxt.js et les applications isomorphiques (Universelles/SSR)Joffrey LEVEUGLE
 
Domain Driven Design (DDD)
Domain Driven Design (DDD)Domain Driven Design (DDD)
Domain Driven Design (DDD)Tom Kocjan
 
Building a Streaming Microservice Architecture: with Apache Spark Structured ...
Building a Streaming Microservice Architecture: with Apache Spark Structured ...Building a Streaming Microservice Architecture: with Apache Spark Structured ...
Building a Streaming Microservice Architecture: with Apache Spark Structured ...Databricks
 
Spring cloud for microservices architecture
Spring cloud for microservices architectureSpring cloud for microservices architecture
Spring cloud for microservices architectureIgor Khotin
 
Event-driven microservices
Event-driven microservicesEvent-driven microservices
Event-driven microservicesAndrew Schofield
 
Microservice Design Patterns.pdf
Microservice Design Patterns.pdfMicroservice Design Patterns.pdf
Microservice Design Patterns.pdfSimform
 
Long running processes in DDD
Long running processes in DDDLong running processes in DDD
Long running processes in DDDBernd Ruecker
 
From Microservices to Service Mesh - devcafe event - July 2018
From Microservices to Service Mesh - devcafe event - July 2018From Microservices to Service Mesh - devcafe event - July 2018
From Microservices to Service Mesh - devcafe event - July 2018Thang Chung
 
Troubleshooting Kerberos in Hadoop: Taming the Beast
Troubleshooting Kerberos in Hadoop: Taming the BeastTroubleshooting Kerberos in Hadoop: Taming the Beast
Troubleshooting Kerberos in Hadoop: Taming the BeastDataWorks Summit
 
Finite State Queries In Lucene
Finite State Queries In LuceneFinite State Queries In Lucene
Finite State Queries In Luceneotisg
 
The Art of Discovering Bounded Contexts
The Art of Discovering Bounded ContextsThe Art of Discovering Bounded Contexts
The Art of Discovering Bounded ContextsNick Tune
 
Implementing Domain-Driven Design (Study Group) Chapter 3 - Context Maps
Implementing Domain-Driven Design (Study Group) Chapter 3 - Context Maps Implementing Domain-Driven Design (Study Group) Chapter 3 - Context Maps
Implementing Domain-Driven Design (Study Group) Chapter 3 - Context Maps Eason Kuo
 
Domain-Driven Design
Domain-Driven DesignDomain-Driven Design
Domain-Driven DesignAndriy Buday
 
Software Architecture Patterns
Software Architecture PatternsSoftware Architecture Patterns
Software Architecture PatternsAssaf Gannon
 
DDD Tactical Design with Clean Architecture - Ivan Paulovich
DDD Tactical Design with Clean Architecture - Ivan PaulovichDDD Tactical Design with Clean Architecture - Ivan Paulovich
DDD Tactical Design with Clean Architecture - Ivan PaulovichIvan Paulovich
 
Domain Driven Design Demonstrated
Domain Driven Design Demonstrated Domain Driven Design Demonstrated
Domain Driven Design Demonstrated Alan Christensen
 

What's hot (20)

CQRS and Event Sourcing
CQRS and Event Sourcing CQRS and Event Sourcing
CQRS and Event Sourcing
 
Nuxt.js et les applications isomorphiques (Universelles/SSR)
Nuxt.js et les applications isomorphiques (Universelles/SSR)Nuxt.js et les applications isomorphiques (Universelles/SSR)
Nuxt.js et les applications isomorphiques (Universelles/SSR)
 
Domain Driven Design (DDD)
Domain Driven Design (DDD)Domain Driven Design (DDD)
Domain Driven Design (DDD)
 
Introduction to DDD
Introduction to DDDIntroduction to DDD
Introduction to DDD
 
Building a Streaming Microservice Architecture: with Apache Spark Structured ...
Building a Streaming Microservice Architecture: with Apache Spark Structured ...Building a Streaming Microservice Architecture: with Apache Spark Structured ...
Building a Streaming Microservice Architecture: with Apache Spark Structured ...
 
Spring cloud for microservices architecture
Spring cloud for microservices architectureSpring cloud for microservices architecture
Spring cloud for microservices architecture
 
Event-driven microservices
Event-driven microservicesEvent-driven microservices
Event-driven microservices
 
Spring Security 5
Spring Security 5Spring Security 5
Spring Security 5
 
Microservice Design Patterns.pdf
Microservice Design Patterns.pdfMicroservice Design Patterns.pdf
Microservice Design Patterns.pdf
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Long running processes in DDD
Long running processes in DDDLong running processes in DDD
Long running processes in DDD
 
From Microservices to Service Mesh - devcafe event - July 2018
From Microservices to Service Mesh - devcafe event - July 2018From Microservices to Service Mesh - devcafe event - July 2018
From Microservices to Service Mesh - devcafe event - July 2018
 
Troubleshooting Kerberos in Hadoop: Taming the Beast
Troubleshooting Kerberos in Hadoop: Taming the BeastTroubleshooting Kerberos in Hadoop: Taming the Beast
Troubleshooting Kerberos in Hadoop: Taming the Beast
 
Finite State Queries In Lucene
Finite State Queries In LuceneFinite State Queries In Lucene
Finite State Queries In Lucene
 
The Art of Discovering Bounded Contexts
The Art of Discovering Bounded ContextsThe Art of Discovering Bounded Contexts
The Art of Discovering Bounded Contexts
 
Implementing Domain-Driven Design (Study Group) Chapter 3 - Context Maps
Implementing Domain-Driven Design (Study Group) Chapter 3 - Context Maps Implementing Domain-Driven Design (Study Group) Chapter 3 - Context Maps
Implementing Domain-Driven Design (Study Group) Chapter 3 - Context Maps
 
Domain-Driven Design
Domain-Driven DesignDomain-Driven Design
Domain-Driven Design
 
Software Architecture Patterns
Software Architecture PatternsSoftware Architecture Patterns
Software Architecture Patterns
 
DDD Tactical Design with Clean Architecture - Ivan Paulovich
DDD Tactical Design with Clean Architecture - Ivan PaulovichDDD Tactical Design with Clean Architecture - Ivan Paulovich
DDD Tactical Design with Clean Architecture - Ivan Paulovich
 
Domain Driven Design Demonstrated
Domain Driven Design Demonstrated Domain Driven Design Demonstrated
Domain Driven Design Demonstrated
 

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

Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Digital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentDigital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentMahmoud Rabie
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
WomenInAutomation2024: AI and Automation for eveyone
WomenInAutomation2024: AI and Automation for eveyoneWomenInAutomation2024: AI and Automation for eveyone
WomenInAutomation2024: AI and Automation for eveyoneUiPathCommunity
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Nikki Chapple
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessWSO2
 

Recently uploaded (20)

Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Digital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentDigital Tools & AI in Career Development
Digital Tools & AI in Career Development
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
WomenInAutomation2024: AI and Automation for eveyone
WomenInAutomation2024: AI and Automation for eveyoneWomenInAutomation2024: AI and Automation for eveyone
WomenInAutomation2024: AI and Automation for eveyone
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with Platformless
 

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