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

Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsAndrey Dotsenko
 

Recently uploaded (20)

Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 

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