SlideShare a Scribd company logo
1 of 29
Download to read offline
orb@nostacktrace.com




                           Vert.x
                             A polyglot
                          asynchronous
                       application platform
Norman Richards




                            for the JVM
orb@nostacktrace.com

                                     Do you need Async?
                                                         Conan, What is
                                                          best in life?




                                                 To crush their servers,
Norman Richards




                                              s! them smoking before you,
                                              and to hear the lamentations
                                                     of their admins!
                                                                 http://www.mikeperham.com/
                       Conan, the C10K Barbarian
orb@nostacktrace.com
                       Ok, so of course that means ...
Norman Richards




                                  http://bit.ly/ACrwel
orb@nostacktrace.com

                        Some Async options

                       Node.js        (JavaScript)
                       Twisted            (Python)
                       Tornado            (Python)
                       EventMachine         (Ruby)
                       Vert.x               (Java)
                       Vert.x         (Javascript)
                       Vert.x             (Python)
Norman Richards




                       Vert.x               (Ruby)
                       Vert.x             (Groovy)
orb@nostacktrace.com

                       Key advantages of vert.x


                        Runs on the JVM (Java 7+)

                        Choose the best language

                        Hybrid evented/threaded model
Norman Richards
orb@nostacktrace.com

                                 Evented IO

                       One thread handles all requests

                       Everything is an event handler

                       Never block the thread

                       Do work quickly + register callbacks
Norman Richards




                       Any kind of service - not just HTTP
orb@nostacktrace.com

                                               simple Example

                       import org.vertx.java.core.Handler;
                       import org.vertx.java.core.http.HttpServerRequest;
                       import org.vertx.java.platform.Verticle;

                       public class ServerExample extends Verticle {

                         public void start() {
                           vertx.createHttpServer().requestHandler(new Handler<HttpServerRequest>() {
                             public void handle(HttpServerRequest req) {
                               req.response.headers().put("Content-Type", "text/html; charset=UTF-8");
                               req.response.end("<html><body><h1>Hello from vert.x!</h1></body></html>");
                             }
Norman Richards




                           }).listen(8080);
                         }
                       }
orb@nostacktrace.com

                                     slightly bigger Example
                       server.requestHandler(new Handler<HttpServerRequest>() {
                           public void handle(HttpServerRequest request) {
                        
                               final Buffer body = new Buffer(0);
                        
                               request.dataHandler(new Handler<Buffer>() {
                                   public void handle(Buffer buffer) {
                                       body.appendBuffer(buffer);
                                   }
                               });

                               request.endHandler(new SimpleHandler() {
                                   public void handle() {
                                     // The entire body has now been received
Norman Richards




                                     log.info("The total body received was " + body.length() + " bytes");
                                   }
                               });
                        
                           }
                       }).listen(8080, "localhost");
orb@nostacktrace.com

                                         the verticle

                                        the unit of management/deployment
                         Event Loop


                                        classloader isolated
                        Event Handler


                        Event Handler
                                        one thread / one event loop
                        Event Handler


                        Event Handler
                                        only one handler running at a time
Norman Richards




                       VERTICLE
                                        no multi-threaded worries
orb@nostacktrace.com

                                 One VERTICLE PER CPU

                                          Shared Connection Load Balancer



                         Event Loop       Event Loop             Event Loop       Event Loop




                        Event Handler    Event Handler          Event Handler    Event Handler


                        Event Handler    Event Handler          Event Handler    Event Handler


                        Event Handler    Event Handler          Event Handler    Event Handler
Norman Richards




                        Event Handler    Event Handler          Event Handler    Event Handler




                       VERTICLE         VERTICLE              VERTICLE          VERTICLE
orb@nostacktrace.com

                       One VERTICLE PER CPU PER HOST

                         Event Loop               Event Loop       Event Loop               Event Loop




                        Event Handler            Event Handler    Event Handler            Event Handler


                        Event Handler            Event Handler    Event Handler            Event Handler


                        Event Handler            Event Handler    Event Handler            Event Handler


                        Event Handler            Event Handler    Event Handler            Event Handler
Norman Richards




                       VERTICLE                 VERTICLE         VERTICLE                 VERTICLE

                                        host1                                     host2
orb@nostacktrace.com

                                                                        SHARED STATE

                         Event Loop                      Event Loop




                        Event Handler                   Event Handler        per-instance “session”
                        Event Handler                   Event Handler


                        Event Handler                   Event Handler        map or set interface
                        Event Handler                   Event Handler



                                                                             only immutable values
Norman Richards




                       VERTICLE                        VERTICLE

                                        Shared State
orb@nostacktrace.com

                                      SHARED MAPs



                       ConcurrentMap<String, Integer> map =
                               vertx.sharedData().getMap("app.interesting-data");
                        
                       map.put("some-key", 123);
                       map.putIfAbsent("some-key", 123);
                       map.replace("some-key", 123, 124);
                       map.get("some-key");
                       map.remove("some-key"); 
Norman Richards
orb@nostacktrace.com

                                         SHARED SETS


                       Set<String> set = vertx.sharedData().getSet("app.active-users");
                        
                       set.add("alfred");
                       set.contains("alfred");
                       set.contains("remove");
Norman Richards
orb@nostacktrace.com

                                      distributed event bus

                         Event Loop                     Event Loop                   Event Loop                     Event Loop




                        Event Handler                  Event Handler                Event Handler                  Event Handler


                        Event Handler                  Event Handler                Event Handler                  Event Handler


                        Event Handler                  Event Handler                Event Handler                  Event Handler


                        Event Handler                  Event Handler                Event Handler                  Event Handler




                       VERTICLE                    VERTICLE                        VERTICLE                    VERTICLE
Norman Richards




                                        Shared State                                                Shared State


                                                                       Event Bus
orb@nostacktrace.com

                          The event bus

                       ad-hoc addressing

                       pubsub or p2p messaging

                       not persistent

                       JSON-based messaging
Norman Richards
orb@nostacktrace.com

                                              The event bus
                       Handler<Message<String>> myHandler = new Handler<Message<String>>() {
                           public void handle(Message<String> message) {
                               System.out.println("I received a message " + message.body);
                        
                               // do work

                               message.reply("This is a reply");
                           }
                       };
                        
                       eb.registerHandler("test.address", myHandler);
                        
                       eb.send("test.address", "This is a message", new Handler<Message<String>>() {
Norman Richards




                           public void handle(Message<String> message) {
                               System.out.println("I received a reply " + message.body);
                           }
                       });
orb@nostacktrace.com

                                          ... in groovy

                       def myHandler = { message ->
                           println "I received a message ${message.body}"

                           // do work

                           message.reply "This is a reply"
                       }
                        
                       eb.registerHandler("test.address", myHandler)

                        
Norman Richards




                       eb.send("test.address", "This is a message") { message ->
                           println "I received a reply ${message.body}"
                       }
orb@nostacktrace.com

                                                    ... in ruby


                       Vertx::EventBus.registerHandler('test.address') do |message|
                         puts("I received a message #{message.body}")
                        
                         # do work
                        
                         message.reply('This is a reply')
                       end
                        
                       Vertx::EventBus.send('test.address', 'This is a message') do |message|
                         puts("I received a reply #{message.body}")
Norman Richards




                       end
orb@nostacktrace.com

                                              ... in python


                       def handler(message):
                           print "I received a message %s" % message.body
                        
                           # do work

                           message.reply('This is a reply')
                        
                       EventBus.registerHandler('test.address', handler)
                        
                       def reply_handler(message):
Norman Richards




                            print "I received a reply %s" % message.body

                       EventBus.send('test.address', 'This is a message', reply_handler)
orb@nostacktrace.com

                                          ... in javscript

                       var myHandler = function(message, replier) {
                          log.info('I received a message ' + message);
                         
                          // Now reply to it
                        
                          replier('This is a reply');
                       }
                        
                       eb.registerHandler('test.address', myHandler);
                        
                       eb.send('test.address', 'This is a message', function(reply) {
Norman Richards




                            log.info('I received a reply ' + reply);
                       });
orb@nostacktrace.com

                                      ... in clojure !!!

                       (defhandle my-handle [message]
                         (println "I received a mesage" (:body message))

                        ;; do work

                        (reply message "This is a reply"))
                        
                       (register-handler event-bus "test.address" my-handle)
                        
                       (send event-bus "test.address"
                             "This is a message"
Norman Richards




                             (handle [response]
                                     (println "I received a reply" (:body response))))
orb@nostacktrace.com


                       WHAT about things that block?


                             blocking IO

                             CPU-intensive operations

                             legacy Java libraries
Norman Richards
orb@nostacktrace.com

                                        WORKER VERTICLES


                         Event Loop       Event Handler       Event Handler    Event Handler


                                          Event Handler       Event Handler    Event Handler
                        Event Handler

                                          Event Handler       Event Handler    Event Handler
                        Event Handler


                        Event Handler

                                         WORKER             WORKER             WORKER

                       VERTICLE                           Worker Thread Pool
Norman Richards
orb@nostacktrace.com

                         more vert.x things


                       timers
                       streams / pumps / buffers
                       module system
                       SockJS / websockets
                       eventbus bridge
Norman Richards




                       outgoing network clients
Norman Richards                     orb@nostacktrace.com




                  http://vertx.io
orb@nostacktrace.com




                          Austin Clojure meetup
                                            Next Meeting:
                                Monday, March 4. 7pm @ Capital Factory
Norman Richards




                       http://www.meetup.com/Austin-Clojure-Meetup/
Norman Richards                           orb@nostacktrace.com




                  http://lambdajam.com/
Norman Richards               orb@nostacktrace.com




                  thank you

More Related Content

Viewers also liked

An Adventure in Serverless ClojureScript
An Adventure in Serverless ClojureScriptAn Adventure in Serverless ClojureScript
An Adventure in Serverless ClojureScriptNorman Richards
 
Clojure talk at Münster JUG
Clojure talk at Münster JUGClojure talk at Münster JUG
Clojure talk at Münster JUGAlex Ott
 
ClojureScript Anatomy
ClojureScript AnatomyClojureScript Anatomy
ClojureScript AnatomyMike Fogus
 
Logic programming a ruby perspective
Logic programming a ruby perspectiveLogic programming a ruby perspective
Logic programming a ruby perspectiveNorman Richards
 
A web app in pure Clojure
A web app in pure ClojureA web app in pure Clojure
A web app in pure ClojureDane Schneider
 
The Lambda Calculus and The JavaScript
The Lambda Calculus and The JavaScriptThe Lambda Calculus and The JavaScript
The Lambda Calculus and The JavaScriptNorman Richards
 

Viewers also liked (14)

core.logic introduction
core.logic introductioncore.logic introduction
core.logic introduction
 
An Adventure in Serverless ClojureScript
An Adventure in Serverless ClojureScriptAn Adventure in Serverless ClojureScript
An Adventure in Serverless ClojureScript
 
Clojure talk at Münster JUG
Clojure talk at Münster JUGClojure talk at Münster JUG
Clojure talk at Münster JUG
 
Clojure 7-Languages
Clojure 7-LanguagesClojure 7-Languages
Clojure 7-Languages
 
Knowledge Extraction
Knowledge ExtractionKnowledge Extraction
Knowledge Extraction
 
Process models
Process modelsProcess models
Process models
 
Immutant
ImmutantImmutant
Immutant
 
Project lifecycle in IT industry
Project lifecycle in IT industryProject lifecycle in IT industry
Project lifecycle in IT industry
 
ClojureScript Anatomy
ClojureScript AnatomyClojureScript Anatomy
ClojureScript Anatomy
 
Logic programming a ruby perspective
Logic programming a ruby perspectiveLogic programming a ruby perspective
Logic programming a ruby perspective
 
Prolog 7-Languages
Prolog 7-LanguagesProlog 7-Languages
Prolog 7-Languages
 
A web app in pure Clojure
A web app in pure ClojureA web app in pure Clojure
A web app in pure Clojure
 
The Lambda Calculus and The JavaScript
The Lambda Calculus and The JavaScriptThe Lambda Calculus and The JavaScript
The Lambda Calculus and The JavaScript
 
Lokijs
LokijsLokijs
Lokijs
 

Similar to Vert.X mini-talk

2010-02-09 Reactor Pattern & Event Driven Programming
2010-02-09 Reactor Pattern & Event Driven Programming2010-02-09 Reactor Pattern & Event Driven Programming
2010-02-09 Reactor Pattern & Event Driven ProgrammingLin Jen-Shin
 
State of the art: Server-Side JavaScript - WebWorkersCamp IV - Open World For...
State of the art: Server-Side JavaScript - WebWorkersCamp IV - Open World For...State of the art: Server-Side JavaScript - WebWorkersCamp IV - Open World For...
State of the art: Server-Side JavaScript - WebWorkersCamp IV - Open World For...Alexandre Morgaut
 
Computer, end program
Computer, end programComputer, end program
Computer, end programSameer Verma
 
Marco Cattaneo "Event data processing in LHCb"
Marco Cattaneo "Event data processing in LHCb"Marco Cattaneo "Event data processing in LHCb"
Marco Cattaneo "Event data processing in LHCb"Yandex
 
Time Series Processing with Apache Spark
Time Series Processing with Apache SparkTime Series Processing with Apache Spark
Time Series Processing with Apache SparkQAware GmbH
 
Time Series Processing with Apache Spark
Time Series Processing with Apache SparkTime Series Processing with Apache Spark
Time Series Processing with Apache SparkJosef Adersberger
 
2010-04-13 Reactor Pattern & Event Driven Programming 2
2010-04-13 Reactor Pattern & Event Driven Programming 22010-04-13 Reactor Pattern & Event Driven Programming 2
2010-04-13 Reactor Pattern & Event Driven Programming 2Lin Jen-Shin
 
Realtime Streaming using Autobahn Websockets
Realtime Streaming using Autobahn WebsocketsRealtime Streaming using Autobahn Websockets
Realtime Streaming using Autobahn WebsocketsTom Sheffler
 
State of the art: Server-Side JavaScript (ParisJS)
State of the art: Server-Side JavaScript  (ParisJS)State of the art: Server-Side JavaScript  (ParisJS)
State of the art: Server-Side JavaScript (ParisJS)Alexandre Morgaut
 
Hadoop Summit Europe 2014: Apache Storm Architecture
Hadoop Summit Europe 2014: Apache Storm ArchitectureHadoop Summit Europe 2014: Apache Storm Architecture
Hadoop Summit Europe 2014: Apache Storm ArchitectureP. Taylor Goetz
 
Building Distributed Systems in Scala
Building Distributed Systems in ScalaBuilding Distributed Systems in Scala
Building Distributed Systems in ScalaAlex Payne
 
Realtime Computation with Storm
Realtime Computation with StormRealtime Computation with Storm
Realtime Computation with Stormboorad
 

Similar to Vert.X mini-talk (20)

Apache con 2011 gd
Apache con 2011 gdApache con 2011 gd
Apache con 2011 gd
 
Usenix lisa 2011
Usenix lisa 2011Usenix lisa 2011
Usenix lisa 2011
 
2010-02-09 Reactor Pattern & Event Driven Programming
2010-02-09 Reactor Pattern & Event Driven Programming2010-02-09 Reactor Pattern & Event Driven Programming
2010-02-09 Reactor Pattern & Event Driven Programming
 
State of the art: Server-Side JavaScript - WebWorkersCamp IV - Open World For...
State of the art: Server-Side JavaScript - WebWorkersCamp IV - Open World For...State of the art: Server-Side JavaScript - WebWorkersCamp IV - Open World For...
State of the art: Server-Side JavaScript - WebWorkersCamp IV - Open World For...
 
Basanta jtr2009
Basanta jtr2009Basanta jtr2009
Basanta jtr2009
 
Computer, end program
Computer, end programComputer, end program
Computer, end program
 
Marco Cattaneo "Event data processing in LHCb"
Marco Cattaneo "Event data processing in LHCb"Marco Cattaneo "Event data processing in LHCb"
Marco Cattaneo "Event data processing in LHCb"
 
Time Series Processing with Apache Spark
Time Series Processing with Apache SparkTime Series Processing with Apache Spark
Time Series Processing with Apache Spark
 
Time Series Processing with Apache Spark
Time Series Processing with Apache SparkTime Series Processing with Apache Spark
Time Series Processing with Apache Spark
 
Node.js in production
Node.js in productionNode.js in production
Node.js in production
 
2010-04-13 Reactor Pattern & Event Driven Programming 2
2010-04-13 Reactor Pattern & Event Driven Programming 22010-04-13 Reactor Pattern & Event Driven Programming 2
2010-04-13 Reactor Pattern & Event Driven Programming 2
 
Realtime Streaming using Autobahn Websockets
Realtime Streaming using Autobahn WebsocketsRealtime Streaming using Autobahn Websockets
Realtime Streaming using Autobahn Websockets
 
State of the art: Server-Side JavaScript (ParisJS)
State of the art: Server-Side JavaScript  (ParisJS)State of the art: Server-Side JavaScript  (ParisJS)
State of the art: Server-Side JavaScript (ParisJS)
 
No Heap Remote Objects for Distributed real-time Java
No Heap Remote Objects for Distributed real-time JavaNo Heap Remote Objects for Distributed real-time Java
No Heap Remote Objects for Distributed real-time Java
 
Hadoop Summit Europe 2014: Apache Storm Architecture
Hadoop Summit Europe 2014: Apache Storm ArchitectureHadoop Summit Europe 2014: Apache Storm Architecture
Hadoop Summit Europe 2014: Apache Storm Architecture
 
Building Distributed Systems in Scala
Building Distributed Systems in ScalaBuilding Distributed Systems in Scala
Building Distributed Systems in Scala
 
Cassandra勉強会
Cassandra勉強会Cassandra勉強会
Cassandra勉強会
 
NoSQL @ Qbranch -2010-04-15
NoSQL @ Qbranch -2010-04-15NoSQL @ Qbranch -2010-04-15
NoSQL @ Qbranch -2010-04-15
 
Vert.x
Vert.xVert.x
Vert.x
 
Realtime Computation with Storm
Realtime Computation with StormRealtime Computation with Storm
Realtime Computation with Storm
 

Recently uploaded

Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
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
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
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
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 

Recently uploaded (20)

Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
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
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
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...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 

Vert.X mini-talk

  • 1. orb@nostacktrace.com Vert.x A polyglot asynchronous application platform Norman Richards for the JVM
  • 2. orb@nostacktrace.com Do you need Async? Conan, What is best in life? To crush their servers, Norman Richards s! them smoking before you, and to hear the lamentations of their admins! http://www.mikeperham.com/ Conan, the C10K Barbarian
  • 3. orb@nostacktrace.com Ok, so of course that means ... Norman Richards http://bit.ly/ACrwel
  • 4. orb@nostacktrace.com Some Async options Node.js (JavaScript) Twisted (Python) Tornado (Python) EventMachine (Ruby) Vert.x (Java) Vert.x (Javascript) Vert.x (Python) Norman Richards Vert.x (Ruby) Vert.x (Groovy)
  • 5. orb@nostacktrace.com Key advantages of vert.x Runs on the JVM (Java 7+) Choose the best language Hybrid evented/threaded model Norman Richards
  • 6. orb@nostacktrace.com Evented IO One thread handles all requests Everything is an event handler Never block the thread Do work quickly + register callbacks Norman Richards Any kind of service - not just HTTP
  • 7. orb@nostacktrace.com simple Example import org.vertx.java.core.Handler; import org.vertx.java.core.http.HttpServerRequest; import org.vertx.java.platform.Verticle; public class ServerExample extends Verticle {   public void start() {     vertx.createHttpServer().requestHandler(new Handler<HttpServerRequest>() {       public void handle(HttpServerRequest req) {         req.response.headers().put("Content-Type", "text/html; charset=UTF-8");         req.response.end("<html><body><h1>Hello from vert.x!</h1></body></html>");       } Norman Richards     }).listen(8080);   } }
  • 8. orb@nostacktrace.com slightly bigger Example server.requestHandler(new Handler<HttpServerRequest>() { public void handle(HttpServerRequest request) {   final Buffer body = new Buffer(0);   request.dataHandler(new Handler<Buffer>() { public void handle(Buffer buffer) { body.appendBuffer(buffer); } }); request.endHandler(new SimpleHandler() { public void handle() { // The entire body has now been received Norman Richards log.info("The total body received was " + body.length() + " bytes"); } });   } }).listen(8080, "localhost");
  • 9. orb@nostacktrace.com the verticle the unit of management/deployment Event Loop classloader isolated Event Handler Event Handler one thread / one event loop Event Handler Event Handler only one handler running at a time Norman Richards VERTICLE no multi-threaded worries
  • 10. orb@nostacktrace.com One VERTICLE PER CPU Shared Connection Load Balancer Event Loop Event Loop Event Loop Event Loop Event Handler Event Handler Event Handler Event Handler Event Handler Event Handler Event Handler Event Handler Event Handler Event Handler Event Handler Event Handler Norman Richards Event Handler Event Handler Event Handler Event Handler VERTICLE VERTICLE VERTICLE VERTICLE
  • 11. orb@nostacktrace.com One VERTICLE PER CPU PER HOST Event Loop Event Loop Event Loop Event Loop Event Handler Event Handler Event Handler Event Handler Event Handler Event Handler Event Handler Event Handler Event Handler Event Handler Event Handler Event Handler Event Handler Event Handler Event Handler Event Handler Norman Richards VERTICLE VERTICLE VERTICLE VERTICLE host1 host2
  • 12. orb@nostacktrace.com SHARED STATE Event Loop Event Loop Event Handler Event Handler per-instance “session” Event Handler Event Handler Event Handler Event Handler map or set interface Event Handler Event Handler only immutable values Norman Richards VERTICLE VERTICLE Shared State
  • 13. orb@nostacktrace.com SHARED MAPs ConcurrentMap<String, Integer> map = vertx.sharedData().getMap("app.interesting-data");   map.put("some-key", 123); map.putIfAbsent("some-key", 123); map.replace("some-key", 123, 124); map.get("some-key"); map.remove("some-key");  Norman Richards
  • 14. orb@nostacktrace.com SHARED SETS Set<String> set = vertx.sharedData().getSet("app.active-users");   set.add("alfred"); set.contains("alfred"); set.contains("remove"); Norman Richards
  • 15. orb@nostacktrace.com distributed event bus Event Loop Event Loop Event Loop Event Loop Event Handler Event Handler Event Handler Event Handler Event Handler Event Handler Event Handler Event Handler Event Handler Event Handler Event Handler Event Handler Event Handler Event Handler Event Handler Event Handler VERTICLE VERTICLE VERTICLE VERTICLE Norman Richards Shared State Shared State Event Bus
  • 16. orb@nostacktrace.com The event bus ad-hoc addressing pubsub or p2p messaging not persistent JSON-based messaging Norman Richards
  • 17. orb@nostacktrace.com The event bus Handler<Message<String>> myHandler = new Handler<Message<String>>() { public void handle(Message<String> message) { System.out.println("I received a message " + message.body);   // do work message.reply("This is a reply"); } };   eb.registerHandler("test.address", myHandler);   eb.send("test.address", "This is a message", new Handler<Message<String>>() { Norman Richards public void handle(Message<String> message) { System.out.println("I received a reply " + message.body); } });
  • 18. orb@nostacktrace.com ... in groovy def myHandler = { message -> println "I received a message ${message.body}"  // do work message.reply "This is a reply" }   eb.registerHandler("test.address", myHandler)   Norman Richards eb.send("test.address", "This is a message") { message -> println "I received a reply ${message.body}" }
  • 19. orb@nostacktrace.com ... in ruby Vertx::EventBus.registerHandler('test.address') do |message| puts("I received a message #{message.body}")   # do work   message.reply('This is a reply') end   Vertx::EventBus.send('test.address', 'This is a message') do |message| puts("I received a reply #{message.body}") Norman Richards end
  • 20. orb@nostacktrace.com ... in python def handler(message): print "I received a message %s" % message.body   # do work message.reply('This is a reply')   EventBus.registerHandler('test.address', handler)   def reply_handler(message): Norman Richards print "I received a reply %s" % message.body EventBus.send('test.address', 'This is a message', reply_handler)
  • 21. orb@nostacktrace.com ... in javscript var myHandler = function(message, replier) { log.info('I received a message ' + message);    // Now reply to it   replier('This is a reply'); }   eb.registerHandler('test.address', myHandler);   eb.send('test.address', 'This is a message', function(reply) { Norman Richards log.info('I received a reply ' + reply); });
  • 22. orb@nostacktrace.com ... in clojure !!! (defhandle my-handle [message] (println "I received a mesage" (:body message)) ;; do work (reply message "This is a reply"))   (register-handler event-bus "test.address" my-handle)   (send event-bus "test.address" "This is a message" Norman Richards (handle [response] (println "I received a reply" (:body response))))
  • 23. orb@nostacktrace.com WHAT about things that block? blocking IO CPU-intensive operations legacy Java libraries Norman Richards
  • 24. orb@nostacktrace.com WORKER VERTICLES Event Loop Event Handler Event Handler Event Handler Event Handler Event Handler Event Handler Event Handler Event Handler Event Handler Event Handler Event Handler Event Handler WORKER WORKER WORKER VERTICLE Worker Thread Pool Norman Richards
  • 25. orb@nostacktrace.com more vert.x things timers streams / pumps / buffers module system SockJS / websockets eventbus bridge Norman Richards outgoing network clients
  • 26. Norman Richards orb@nostacktrace.com http://vertx.io
  • 27. orb@nostacktrace.com Austin Clojure meetup Next Meeting: Monday, March 4. 7pm @ Capital Factory Norman Richards http://www.meetup.com/Austin-Clojure-Meetup/
  • 28. Norman Richards orb@nostacktrace.com http://lambdajam.com/
  • 29. Norman Richards orb@nostacktrace.com thank you