SlideShare ist ein Scribd-Unternehmen logo
1 von 74
Downloaden Sie, um offline zu lesen
Vert.x:
                   This ain’t your Dad’s Node!




                                           Matt Stine
   Tim Fox
                   Enterprise Java/Cloud Consultant
Father of Vert.x
                               matt.stine@gmail.com
                                http://mattstine.com
                                     Twitter: @mstine
The

C10K
 Problem
SERVER
 PUSH
Ryan Dahl
Father of Node.js




  How?!?!
2008:

Thread Per Request/Response
http://www.xtranormal.com/watch/6995033/mongo-db-is-web-scale
Non-blocking UNIX sockets
But Node
has some
shortcomings...

 1. JavaScript!

 2. Vertical Scaling

 3. Interprocess
 Communication

 4. Event Loop
http://vertx.io
Problem #1:

                       JavaScript


   Brendan Eich
Father of JavaScript
WAT
https://www.destroyallsoftware.com/talks/wat
Solution #1:

                                   Polyglot
                                 Programming
           Neal Ford
Father of Polyglot Programming


    http://memeagora.blogspot.com/2006/12/polyglot-programming.html
Hello World
in every Vert.x language!
Java
Ruby
Python
JavaScript
FUTURE



Theoretically, any JVM language or language that compiles
to a supported language (e.g. ClojureScript ➔ JavaScript)
Problem #2:

    Vertical
    Scaling

Lars Bak
Father of V8
http://nodejs.org/about/
Node: Up and Running
Example 3-11: Using cluster to distribute work
Solution #2:

                 The
                 JVM
James Gosling
Father of Java
The Verticle


               - Unit of Deployment
Verticle

               - Script/Java Class
Vert.x Instance
  How it works it works it works it works
          How      How      How

                             Event loop Event loop Event loop Event loop
Event Loops
    App registers App registers App registers App registers trigger Events trigger Events trigger Events trigg
                                                     Events
      handlers      handlers      handlers      handlershandlers      handlers       handlers       handlers



  • Handlers executed synchronously executed synchronously
              • Handlers executed synchronously executed synchronously
                          • Handlers • Handlers
    – on a single threada single threada single threada single thread
                    – on           – on           – on
  • Use handlersUse handlersUse handlersUse handlers to pass messages
                 • to pass messages messages messages
                                • to pass • to pass
  • Inter/intra application comms
                 • Inter/intra application comms
                                • Inter/intra application comms
                                               • Inter/intra application comms
    – EventBus with EventBus with EventBus with EventBus with messages
                  – messages – messages – messages
    – Safe shared data structuresdata structuresdata structuresdata structures
                  – Safe shared – Safe shared – Safe shared
                             Verticle                                   9         9             9




Runtime.availableProcessors() == 4
Vert.x Instance
              How it works it works it works it works
                      How      How      How

                                         Event loop Event loop Event loop Event loop
         Event Loops
                App registers App registers App registers App registers trigger Events trigger Events trigger Events trigg
                                                                 Events
                  handlers      handlers      handlers      handlershandlers      handlers       handlers       handlers



              • Handlers executed synchronously executed synchronously
                          • Handlers executed synchronously executed synchronously
                                      • Handlers • Handlers
                – on a single threada single threada single threada single thread
                                – on           – on           – on
              • Use handlersUse handlersUse handlersUse handlers to pass messages
                             • to pass messages messages messages
                                            • to pass • to pass
 vertx run    • Inter/intra application comms
                             • Inter/intra application comms
                                            • Inter/intra application comms
                                                           • Inter/intra application comms
 HelloWorld with EventBus with EventBus with EventBus with messages
       – EventBus – messages – messages – messages
       – Safe shared data structuresdata structuresdata structuresdata structures
                     – Safe shared – Safe shared – Safe shared
-instances 4                    Verticle Verticle Verticle Verticle                 9         9             9




       Runtime.availableProcessors() == 4
Concurrency
• Verticle instance assigned thread/event loop.
• Verticle instance ALWAYS executes on
  assigned thread.

• Verticles have isolated classloaders and
  cannot share global state (static members,
  global variables, etc.)

• Can write all code assuming single
  threading.
Tony Hoare
        Father of CSP
        (http://dl.acm.org/citation.cfm?
        doid=359576.359585)




              Problem #3:

  Interprocess
Communication
Node.js Communication Options
• TCP/UDP/UNIX Sockets
• Redis Pub/Sub (http://redis.io/)
• ZeroMQ (http://www.zeromq.org/)
• Process Signaling/Cluster Module
• Eventing Frameworks: Hook.io (dead), JS-
  Signals, Bean, etc.

• Memcached
• Etc...
Solution #3.1:

                       The
                      Event
                       Bus
    Alan Kay
Father of Smalltalk
How it works it works it works it works
        How      How      How

                           Event loop Event loop Event loop Event loop

  App registers App registers App registers App registers trigger Events trigger Events trigger Events trigger
                                                   Events
    handlers      handlers      handlers      handlershandlers      handlers       handlers       handlers



• Handlers executed synchronously executed synchronously
            • Handlers executed synchronously executed synchronously
                        • Handlers • Handlers
  – on a single threada single threada single threada single thread
                  – on           – on           – on
• Use handlersUse handlersUse handlersUse handlers to pass messages
               • to pass messages messages messages
                              • to pass • to pass
• Inter/intra application comms
               • Inter/intra application comms
                              • Inter/intra application comms
                                             • Inter/intra application comms
  – EventBus with EventBus with EventBus with EventBus with messages
                – messages – messages – messages
  – Safe shared data structuresdata structuresdata structuresdata structures
                – Safe shared – Safe shared – Safe shared
                            Verticle       Verticle Verticle Verticle 9         9             9              9




                                           Event Bus
Addressing


• Simply a String
• Dot-style namespacing recommended
• e.g. “messages.inbound.A”
Handler Registration
                     Handler X




messages.inbound.A   Handler Y




                     Handler Z
Handler Registration
Pub/Sub
                              Handler X




Sender   messages.inbound.A   Handler Y




                              Handler Z
Pub/Sub
P2P
                              Handler X




Sender   messages.inbound.A   Handler Y




                              Handler Z
P2P
Sender:




Receiver:
Message Types

• String
• Primitives (int, long, short, float, double, ...)
• Boxed Primitives
• boolean/Boolean
• org.vertx.java.core.json.JsonObject
• org.vertx.java.core.buffer.Buffer
Distributed Vert.x
 orks it works it works it works
 How       How     How                                             How it works it works it works it works
                                                                           How       How     How                                                 How it works it works it works it works
                                                                                                                                                          How     How       How

               Event loop Event loop Event loop Event loop                                   Event loop Event loop Event loop Event loop                                   Event loop Event loop Event loop Event loop

rs App registers App registers App registers trigger Events trigger Events trigger Events trigger registers App registers trigger Events trigger Events trigger Events trigger registers App registers trigger Events trigger Events trigger
                                       Events                    App registers App registers App                    Events                   App registers App registers App                    Events
     handlers      handlers      handlershandlers      handlers handlers
                                                                      handlers handlers
                                                                                     handlers handlers        handlershandlers      handlers handlers
                                                                                                                                                   handlers handlers
                                                                                                                                                                  handlers handlers        handlershandlers      handlers       handlers



executed synchronously executed synchronously
 • Handlers executed synchronously executed synchronously
             • Handlers • Handlers                  • Handlers executed synchronously executed synchronously
                                                                • Handlers executed synchronously executed synchronously
                                                                            • Handlers • Handlers                  • Handlers executed synchronously executed synchronously
                                                                                                                               • Handlers executed synchronously executed synchronously
                                                                                                                                           • Handlers • Handlers
le threada single threada single threada single thread
     – on           – on           – on                             – on a single threada single threada single threada single thread
                                                                                    – on           – on           – on                            – on a single threada single threada single threada single thread
                                                                                                                                                                  – on           – on           – on
ersUsepass messages messages messages messages handlersUsepass messages messages messages messages handlersUse handlersUsepass messages messages messages
 • to handlersUse handlersUsepass
                • to pass • to handlers to pass               • Use          • to handlersUse handlersUsepass
                                                                                            • to pass • to handlers to pass              • Use          • to pass messages
                                                                                                                                                                       • to handlersUse handlers to pass
                                                                                                                                                                                      • to pass
application comms
 • Inter/intra application comms
                • Inter/intra application comms
                               • Inter/intra application comms• Inter/intra application comms
                                                                             • Inter/intra application comms
                                                                                            • Inter/intra application comms
                                                                                                           • Inter/intra application comms Inter/intra application comms
                                                                                                                                         •              • Inter/intra application comms
                                                                                                                                                                       • Inter/intra application comms
                                                                                                                                                                                      • Inter/intra application comms
s with EventBus with EventBus with EventBus with messages
     – messages – messages – messages                               – EventBus with EventBus with EventBus with EventBus with messages
                                                                                  – messages – messages – messages                                – EventBus with EventBus with EventBus with EventBus with messages
                                                                                                                                                                – messages – messages – messages
red data structuresdata structuresdata structuresdata structures
     – Safe shared – Safe shared – Safe shared                      – Safe shared data structuresdata structuresdata structuresdata structures
                                                                                  – Safe shared – Safe shared – Safe shared                       – Safe shared data structuresdata structuresdata structuresdata structures
                                                                                                                                                                – Safe shared – Safe shared – Safe shared
                Verticle       Verticle      Verticle    9
                                                             Verticle9              9
                                                                                              Verticle
                                                                                                   9
                                                                                                             Verticle       Verticle    9
                                                                                                                                            Verticle
                                                                                                                                                   9              9
                                                                                                                                                                            Verticle
                                                                                                                                                                                 9
                                                                                                                                                                                           Verticle       Verticle    9
                                                                                                                                                                                                                          Verticle
                                                                                                                                                                                                                                 9         9




                                                                                                       Event Bus
Into the Browser!
 orks it works it works it works
 How       How     How                                             How it works it works it works it works
                                                                           How       How     How

               Event loop Event loop Event loop Event loop                                   Event loop Event loop Event loop Event loop

rs App registers App registers App registers trigger Events trigger Events trigger Events trigger registers App registers trigger Events trigger Events trigger Events trigger
                                       Events                    App registers App registers App                    Events
     handlers      handlers      handlershandlers      handlers handlers
                                                                      handlers handlers
                                                                                     handlers handlers        handlershandlers      handlers       handlers       handlers



executed synchronously executed synchronously
 • Handlers executed synchronously executed synchronously
             • Handlers • Handlers                  • Handlers executed synchronously executed synchronously
                                                                • Handlers executed synchronously executed synchronously
                                                                            • Handlers • Handlers
le threada single threada single threada single thread
     – on           – on           – on                             – on a single threada single threada single threada single thread
                                                                                    – on           – on           – on
ersUsepass messages messages messages messages handlersUsepass messages messages messages messages
 • to handlersUse handlersUsepass
                • to pass • to handlers to pass               • Use          • to handlersUse handlersUsepass
                                                                                            • to pass • to handlers to pass
application comms
 • Inter/intra application comms
                • Inter/intra application comms
                               • Inter/intra application comms• Inter/intra application comms
                                                                             • Inter/intra application comms
                                                                                            • Inter/intra application comms
                                                                                                           • Inter/intra application comms
s with EventBus with EventBus with EventBus with messages
     – messages – messages – messages                               – EventBus with EventBus with EventBus with EventBus with messages
                                                                                  – messages – messages – messages
red data structuresdata structuresdata structuresdata structures
     – Safe shared – Safe shared – Safe shared                      – Safe shared data structuresdata structuresdata structuresdata structures
                                                                                  – Safe shared – Safe shared – Safe shared
                Verticle       Verticle      Verticle    9
                                                             Verticle9              9
                                                                                              Verticle
                                                                                                   9
                                                                                                             Verticle       Verticle    9
                                                                                                                                            Verticle
                                                                                                                                                   9          9              9




                                                                                                                                                                             SockJS Bridge

                                                                                                       Event Bus
The Server
The Client
Demo
Solution #3.2:

                      Shared
                    Immutable
                       State
  Rich Hickey
Father of Clojure
e.g. In-memory Web
        Cache
MessageAI L
        Passing?
      F
Shared state only
dangerous if it is
   MUTABLE!
Vert.x Shared State
• SharedData Object (vertx.sharedData())
 • collection of
    java.util.concurrent.ConcurrentMap<K,V>

 • collection of java.util.Set<E> (backed by
    ConcurrentMap)

• Elements MUST be immutable values (well,
  sort of...)

• Currently only available within a Vertx.
  instance, not across a cluster.
Allowed Values
• Strings
• Boxed Primitives
•byte[]
                              R !
•org.vertx.java.core.buffer.Buffer
• Implementors of
                        G   E
 Shareable
                      AN
 org.vertx.java.core.shareddata.


                    D
Shared Map
Shared Set
Problem #4:

                                 The
                                Event
                                Loop
     Douglas Schmidt
Father of the Reactor Pattern
Reactor
w it works           Pattern Review

                     Event loop
   Application                     ...events
pp registers
   registers                          Events t
                                      trigger
 handlers                                 handl
   handlers...                    handlers.

                     Event Loop
andlers executed synchronously
on a single thread
se handlers to pass messages
Reactor Pattern Review


• Single thread / single event loop
• EVERYTHING runs on it
• You MUST NOT block the event loop
Reactor Pattern Problems

• Some work is naturally blocking:
 • Intensive data crunching
 • 3rd-party blocking API’s (e.g. JDBC)
• Pure reactor (e.g. Node.js) is not a good fit
  for this kind of work!
Solution #4:

                             Worker
                            Verticles
       Carl Hewitt
Father of the Actor Model
Worker Verticles
• Not assigned a Vert.x event loop thread
• Executes on background thread pool
• Never executed concurrently by more than
  one thread

• Not allowed to use TCP or HTTP clients/
  servers

• Communicate using the event bus
• Should be kept to a minimum
The “Multi-reactor”
How it works it works it works it works
        How       How     How

                           Event loop Event loop Event loop Event loop

                                                                                       BG            BG
  App registers App registers App registers App registers trigger Events trigger Events trigger Events trigger
                                                    Events
    handlers      handlers      handlers      handlershandlers      handlers
                                                                                      Pool
                                                                                   handlers
                                                                                                    Pool
                                                                                                  handlers



• Handlers executed synchronously executed synchronously
            • Handlers executed synchronously executed synchronously
                        • Handlers • Handlers
  – on a single threada single threada single threada single thread
                  – on           – on           – on
• Use handlersUse handlersUse handlersUse handlers to pass messages
               • to pass messages messages messages
                              • to pass • to pass
• Inter/intra application comms
               • Inter/intra application comms
                              • Inter/intra application comms
                                             • Inter/intra application comms
  – EventBus with EventBus with EventBus with EventBus with messages
                – messages – messages – messages
  – Safe shared data structuresdata structuresdata structuresdata structures
                – Safe shared – Safe shared – Safe shared
                                                                                     Worker        Worker
                            Verticle       Verticle       Verticle        Verticle
                                                                                     Verticle      Verticle
                                                                      9          9            9              9




                                                     Event Bus
Problem/Solution Summary


• Node.js compels the use of JavaScript
• Vert.x is Polyglot
• Node.js is inherently single-threaded
• Vert.x leverages the multi-threaded JVM
Problem/Solution Summary
• Node.js doesn’t help much w/ interprocess
  communication

• Vert.x features a distributed event bus which
  reaches all the way into the browser

• Node.js requires all code to run on the event
  loop

• Vert.x features background workers that
  allow blocking work to be done off of the
  event loops
Other Goodies
• Growing Module        • TCP/SSL servers/clients
  Repository            • HTTP/HTTPS servers/
                          clients
 •  web server

 • persistors (Mongo,   • WebSockets support
    JDBC, ...)          • SockJS support
 • work queue           • Timers
 • authentication       • Buffers
    manager
                        • Streams and Pumps
 • session manager      • Routing
 • Socket.IO            • Asynchronous File I/O
Case Study




https://github.com/mstine/twitx
Get Involved!
• Google Group: http://groups.google.com/
  group/vertx

• GitHub: https://github.com/vert-x/vert.x
• IRC: irc://freenode.net/vertx
• Needs:
 • language implementations
 • modules (esp. persistence, security, ...)
 • examples/blogs/documentation help
Vert.x:
                                     This ain’t your Dad’s Node!




                                                             Matt Stine
                                     Enterprise Java/Cloud Consultant
   Please fill out an evaluation:
                                                 matt.stine@gmail.com
                                                  http://mattstine.com
http://speakerrate.com/talks/16821
                                                       Twitter: @mstine
Image Credits
•   Tim Fox: https://twitter.com/timfox

•   BSOD Phone: http://www.flickr.com/photos/markhillary/3413357033

•   V8: http://www.flickr.com/photos/gorbould/3479298062

•   Ryan Dahl: http://www.flickr.com/photos/franksvalli/5163205409

•   Shortcomings: http://www.flickr.com/photos/hendricksphotos/3340896056

•   Brendan Eich: http://www.flickr.com/photos/equanimity/4055148344

•   Neal Ford: http://nealford.com/images/Neal-2012-headshot.jpg

•   Lars Bak: http://www.flickr.com/photos/niallkennedy/2822229099

•   James Gosling: http://www.flickr.com/photos/skrb/2499736195

•   Tony Hoare: http://www.flickr.com/photos/adewale_oshineye/3687557065

•   Alan Kay: http://www.flickr.com/photos/mwichary/3010026816

•   Rich Hickey: http://www.flickr.com/photos/hlship/3603090614

•   Douglas Schmidt: http://www.cs.wustl.edu/~schmidt/gifs/SchmidtD.jpg

•   Carl Hewitt: http://www.flickr.com/photos/jeanbaptisteparis/3098594954

Weitere ähnliche Inhalte

Was ist angesagt?

Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안
SANG WON PARK
 

Was ist angesagt? (20)

Fundamental of ELK Stack
Fundamental of ELK StackFundamental of ELK Stack
Fundamental of ELK Stack
 
Visualizing large datasets with js using deckgl
Visualizing large datasets with js using deckglVisualizing large datasets with js using deckgl
Visualizing large datasets with js using deckgl
 
Spring Boot+Kafka: the New Enterprise Platform
Spring Boot+Kafka: the New Enterprise PlatformSpring Boot+Kafka: the New Enterprise Platform
Spring Boot+Kafka: the New Enterprise Platform
 
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안
 
Understanding MicroSERVICE Architecture with Java & Spring Boot
Understanding MicroSERVICE Architecture with Java & Spring BootUnderstanding MicroSERVICE Architecture with Java & Spring Boot
Understanding MicroSERVICE Architecture with Java & Spring Boot
 
Kubernetes
KubernetesKubernetes
Kubernetes
 
Cluster-as-code. The Many Ways towards Kubernetes
Cluster-as-code. The Many Ways towards KubernetesCluster-as-code. The Many Ways towards Kubernetes
Cluster-as-code. The Many Ways towards Kubernetes
 
Delivering: from Kafka to WebSockets | Adam Warski, SoftwareMill
Delivering: from Kafka to WebSockets | Adam Warski, SoftwareMillDelivering: from Kafka to WebSockets | Adam Warski, SoftwareMill
Delivering: from Kafka to WebSockets | Adam Warski, SoftwareMill
 
InfluxDb
InfluxDbInfluxDb
InfluxDb
 
.NET에서 비동기 프로그래밍 배우기
.NET에서 비동기 프로그래밍 배우기.NET에서 비동기 프로그래밍 배우기
.NET에서 비동기 프로그래밍 배우기
 
kubernetes, pourquoi et comment
kubernetes, pourquoi et commentkubernetes, pourquoi et comment
kubernetes, pourquoi et comment
 
NATS vs HTTP
NATS vs HTTPNATS vs HTTP
NATS vs HTTP
 
Microservices Platform with Spring Boot, Spring Cloud Config, Spring Cloud Ne...
Microservices Platform with Spring Boot, Spring Cloud Config, Spring Cloud Ne...Microservices Platform with Spring Boot, Spring Cloud Config, Spring Cloud Ne...
Microservices Platform with Spring Boot, Spring Cloud Config, Spring Cloud Ne...
 
InfluxDB 101 - Concepts and Architecture | Michael DeSa | InfluxData
InfluxDB 101 - Concepts and Architecture | Michael DeSa | InfluxDataInfluxDB 101 - Concepts and Architecture | Michael DeSa | InfluxData
InfluxDB 101 - Concepts and Architecture | Michael DeSa | InfluxData
 
Event Driven Systems with Spring Boot, Spring Cloud Streams and Kafka
Event Driven Systems with Spring Boot, Spring Cloud Streams and KafkaEvent Driven Systems with Spring Boot, Spring Cloud Streams and Kafka
Event Driven Systems with Spring Boot, Spring Cloud Streams and Kafka
 
Installing and Configuring NGINX Open Source
Installing and Configuring NGINX Open SourceInstalling and Configuring NGINX Open Source
Installing and Configuring NGINX Open Source
 
[Webinar]: Working with Reactive Spring
[Webinar]: Working with Reactive Spring[Webinar]: Working with Reactive Spring
[Webinar]: Working with Reactive Spring
 
containerd the universal container runtime
containerd the universal container runtimecontainerd the universal container runtime
containerd the universal container runtime
 
Kubernetes Introduction
Kubernetes IntroductionKubernetes Introduction
Kubernetes Introduction
 
Odoo development
Odoo developmentOdoo development
Odoo development
 

Andere mochten auch

Vert.x introduction
Vert.x introductionVert.x introduction
Vert.x introduction
GR8Conf
 
Java 7, 8 & 9 - Moving the language forward
Java 7, 8 & 9 - Moving the language forwardJava 7, 8 & 9 - Moving the language forward
Java 7, 8 & 9 - Moving the language forward
Mario Fusco
 
No more loops with lambdaj
No more loops with lambdajNo more loops with lambdaj
No more loops with lambdaj
Mario Fusco
 
SockJS Intro
SockJS IntroSockJS Intro
SockJS Intro
Ngoc Dao
 
Introduction to Remote Procedure Call
Introduction to Remote Procedure CallIntroduction to Remote Procedure Call
Introduction to Remote Procedure Call
Abdelrahman Al-Ogail
 

Andere mochten auch (20)

Vert.x introduction
Vert.x introductionVert.x introduction
Vert.x introduction
 
Vert.x 3
Vert.x 3Vert.x 3
Vert.x 3
 
Vert.x devoxx london 2013
Vert.x devoxx london 2013Vert.x devoxx london 2013
Vert.x devoxx london 2013
 
Vert.x – The problem of real-time data binding
Vert.x – The problem of real-time data bindingVert.x – The problem of real-time data binding
Vert.x – The problem of real-time data binding
 
Vert.x v3 - high performance polyglot application toolkit
Vert.x v3 - high performance  polyglot application toolkitVert.x v3 - high performance  polyglot application toolkit
Vert.x v3 - high performance polyglot application toolkit
 
Building microservices with vert.x 3.0
Building microservices with vert.x 3.0Building microservices with vert.x 3.0
Building microservices with vert.x 3.0
 
Vert.X: Microservices Were Never So Easy (Clement Escoffier)
Vert.X: Microservices Were Never So Easy (Clement Escoffier)Vert.X: Microservices Were Never So Easy (Clement Escoffier)
Vert.X: Microservices Were Never So Easy (Clement Escoffier)
 
Максим Сабарня и Иван Дрижирук “Vert.x – tool-kit for building reactive app...
 	Максим Сабарня и Иван Дрижирук “Vert.x – tool-kit for building reactive app... 	Максим Сабарня и Иван Дрижирук “Vert.x – tool-kit for building reactive app...
Максим Сабарня и Иван Дрижирук “Vert.x – tool-kit for building reactive app...
 
Vert.x
Vert.xVert.x
Vert.x
 
Vert.x using Groovy - Simplifying non-blocking code
Vert.x using Groovy - Simplifying non-blocking codeVert.x using Groovy - Simplifying non-blocking code
Vert.x using Groovy - Simplifying non-blocking code
 
Java 7, 8 & 9 - Moving the language forward
Java 7, 8 & 9 - Moving the language forwardJava 7, 8 & 9 - Moving the language forward
Java 7, 8 & 9 - Moving the language forward
 
Production ready Vert.x
Production ready Vert.xProduction ready Vert.x
Production ready Vert.x
 
No more loops with lambdaj
No more loops with lambdajNo more loops with lambdaj
No more loops with lambdaj
 
SockJS Intro
SockJS IntroSockJS Intro
SockJS Intro
 
High performance network programming on the jvm oscon 2012
High performance network programming on the jvm   oscon 2012 High performance network programming on the jvm   oscon 2012
High performance network programming on the jvm oscon 2012
 
Pro Postgres 9
Pro Postgres 9Pro Postgres 9
Pro Postgres 9
 
Development with Vert.x: an event-driven application framework for the JVM
Development with Vert.x: an event-driven application framework for the JVMDevelopment with Vert.x: an event-driven application framework for the JVM
Development with Vert.x: an event-driven application framework for the JVM
 
2013 빅데이터 및 API 기술 현황과 전망- 윤석찬
2013 빅데이터 및 API 기술 현황과 전망- 윤석찬2013 빅데이터 및 API 기술 현황과 전망- 윤석찬
2013 빅데이터 및 API 기술 현황과 전망- 윤석찬
 
Introduction to Remote Procedure Call
Introduction to Remote Procedure CallIntroduction to Remote Procedure Call
Introduction to Remote Procedure Call
 
ZeroMQ Is The Answer
ZeroMQ Is The AnswerZeroMQ Is The Answer
ZeroMQ Is The Answer
 

Ähnlich wie Vert.x

Open Cloud Interop Public
Open Cloud Interop PublicOpen Cloud Interop Public
Open Cloud Interop Public
rvanhoe
 
Test driven infrastructure development (2 - puppetconf 2013 edition)
Test driven infrastructure development (2 - puppetconf 2013 edition)Test driven infrastructure development (2 - puppetconf 2013 edition)
Test driven infrastructure development (2 - puppetconf 2013 edition)
Tomas Doran
 
Reactive applications and Akka intro used in the Madrid Scala Meetup
Reactive applications and Akka intro used in the Madrid Scala MeetupReactive applications and Akka intro used in the Madrid Scala Meetup
Reactive applications and Akka intro used in the Madrid Scala Meetup
Miguel Pastor
 

Ähnlich wie Vert.x (20)

The bigrabbit
The bigrabbitThe bigrabbit
The bigrabbit
 
Alvaro Videla, Building a Distributed Data Ingestion System with RabbitMQ
Alvaro Videla, Building a Distributed Data Ingestion System with RabbitMQAlvaro Videla, Building a Distributed Data Ingestion System with RabbitMQ
Alvaro Videla, Building a Distributed Data Ingestion System with RabbitMQ
 
Open Cloud Interop Public
Open Cloud Interop PublicOpen Cloud Interop Public
Open Cloud Interop Public
 
Rugged DevOps Will help you build ur cloudz
Rugged DevOps Will help you build ur cloudzRugged DevOps Will help you build ur cloudz
Rugged DevOps Will help you build ur cloudz
 
The influence of "Distributed platforms" on #devops
The influence of "Distributed platforms" on #devopsThe influence of "Distributed platforms" on #devops
The influence of "Distributed platforms" on #devops
 
Your Goat Anti-Fragiled My Snowflake! Demystifying DevOps Jargon (30 minute v...
Your Goat Anti-Fragiled My Snowflake! Demystifying DevOps Jargon (30 minute v...Your Goat Anti-Fragiled My Snowflake! Demystifying DevOps Jargon (30 minute v...
Your Goat Anti-Fragiled My Snowflake! Demystifying DevOps Jargon (30 minute v...
 
Your Goat Anti-Fragiled My SnowFlake! Demystifying DevOps Jargon
Your Goat Anti-Fragiled My SnowFlake! Demystifying DevOps JargonYour Goat Anti-Fragiled My SnowFlake! Demystifying DevOps Jargon
Your Goat Anti-Fragiled My SnowFlake! Demystifying DevOps Jargon
 
Go Reactive: Event-Driven, Scalable, Resilient & Responsive Systems
Go Reactive: Event-Driven, Scalable, Resilient & Responsive SystemsGo Reactive: Event-Driven, Scalable, Resilient & Responsive Systems
Go Reactive: Event-Driven, Scalable, Resilient & Responsive Systems
 
Test driven infrastructure development (2 - puppetconf 2013 edition)
Test driven infrastructure development (2 - puppetconf 2013 edition)Test driven infrastructure development (2 - puppetconf 2013 edition)
Test driven infrastructure development (2 - puppetconf 2013 edition)
 
Metasploitation part-1 (murtuja)
Metasploitation part-1 (murtuja)Metasploitation part-1 (murtuja)
Metasploitation part-1 (murtuja)
 
Spark Summit EU talk by Ruben Pulido and Behar Veliqi
Spark Summit EU talk by Ruben Pulido and Behar VeliqiSpark Summit EU talk by Ruben Pulido and Behar Veliqi
Spark Summit EU talk by Ruben Pulido and Behar Veliqi
 
Spark Summit - Watson Analytics for Social Media: From single tenant Hadoop t...
Spark Summit - Watson Analytics for Social Media: From single tenant Hadoop t...Spark Summit - Watson Analytics for Social Media: From single tenant Hadoop t...
Spark Summit - Watson Analytics for Social Media: From single tenant Hadoop t...
 
Reactive applications and Akka intro used in the Madrid Scala Meetup
Reactive applications and Akka intro used in the Madrid Scala MeetupReactive applications and Akka intro used in the Madrid Scala Meetup
Reactive applications and Akka intro used in the Madrid Scala Meetup
 
Erlang at Nu Echo
Erlang at Nu EchoErlang at Nu Echo
Erlang at Nu Echo
 
Spark Summit EU talk by Ruben Pulido Behar Veliqi
Spark Summit EU talk by Ruben Pulido Behar VeliqiSpark Summit EU talk by Ruben Pulido Behar Veliqi
Spark Summit EU talk by Ruben Pulido Behar Veliqi
 
Erjang - A journey into Erlang-land
Erjang - A journey into Erlang-landErjang - A journey into Erlang-land
Erjang - A journey into Erlang-land
 
Containing the world with Docker
Containing the world with DockerContaining the world with Docker
Containing the world with Docker
 
Adventures in a Microservice world at REA Group
Adventures in a Microservice world at REA GroupAdventures in a Microservice world at REA Group
Adventures in a Microservice world at REA Group
 
Next Generation Cloud: Rise of the Unikernel V3 (UPDATED)
Next Generation Cloud: Rise of the Unikernel V3 (UPDATED)Next Generation Cloud: Rise of the Unikernel V3 (UPDATED)
Next Generation Cloud: Rise of the Unikernel V3 (UPDATED)
 
CPOSC2014: Next Generation Cloud -- Rise of the Unikernel
CPOSC2014: Next Generation Cloud -- Rise of the UnikernelCPOSC2014: Next Generation Cloud -- Rise of the Unikernel
CPOSC2014: Next Generation Cloud -- Rise of the Unikernel
 

Mehr von Matt Stine

Cloud Foundry Diego: Modular and Extensible Substructure for Microservices
Cloud Foundry Diego: Modular and Extensible Substructure for MicroservicesCloud Foundry Diego: Modular and Extensible Substructure for Microservices
Cloud Foundry Diego: Modular and Extensible Substructure for Microservices
Matt Stine
 
Cloud Foundry and Microservices: A Mutualistic Symbiotic Relationship
Cloud Foundry and Microservices: A Mutualistic Symbiotic RelationshipCloud Foundry and Microservices: A Mutualistic Symbiotic Relationship
Cloud Foundry and Microservices: A Mutualistic Symbiotic Relationship
Matt Stine
 
Information Sciences Solutions to Core Facility Problems at St. Jude Children...
Information Sciences Solutions to Core Facility Problems at St. Jude Children...Information Sciences Solutions to Core Facility Problems at St. Jude Children...
Information Sciences Solutions to Core Facility Problems at St. Jude Children...
Matt Stine
 

Mehr von Matt Stine (20)

Architectures That Bend but Don't Break
Architectures That Bend but Don't BreakArchitectures That Bend but Don't Break
Architectures That Bend but Don't Break
 
Cloud Native Architecture Patterns Tutorial
Cloud Native Architecture Patterns TutorialCloud Native Architecture Patterns Tutorial
Cloud Native Architecture Patterns Tutorial
 
Resilient Architecture
Resilient ArchitectureResilient Architecture
Resilient Architecture
 
Cloud Foundry: The Best Place to Run Microservices
Cloud Foundry: The Best Place to Run MicroservicesCloud Foundry: The Best Place to Run Microservices
Cloud Foundry: The Best Place to Run Microservices
 
Reactive Fault Tolerant Programming with Hystrix and RxJava
Reactive Fault Tolerant Programming with Hystrix and RxJavaReactive Fault Tolerant Programming with Hystrix and RxJava
Reactive Fault Tolerant Programming with Hystrix and RxJava
 
Lattice: A Cloud-Native Platform for Your Spring Applications
Lattice: A Cloud-Native Platform for Your Spring ApplicationsLattice: A Cloud-Native Platform for Your Spring Applications
Lattice: A Cloud-Native Platform for Your Spring Applications
 
The Cloud Native Journey
The Cloud Native JourneyThe Cloud Native Journey
The Cloud Native Journey
 
To Microservices and Beyond
To Microservices and BeyondTo Microservices and Beyond
To Microservices and Beyond
 
Deploying Microservices to Cloud Foundry
Deploying Microservices to Cloud FoundryDeploying Microservices to Cloud Foundry
Deploying Microservices to Cloud Foundry
 
Cloud Foundry Diego: Modular and Extensible Substructure for Microservices
Cloud Foundry Diego: Modular and Extensible Substructure for MicroservicesCloud Foundry Diego: Modular and Extensible Substructure for Microservices
Cloud Foundry Diego: Modular and Extensible Substructure for Microservices
 
Building Distributed Systems with Netflix OSS and Spring Cloud
Building Distributed Systems with Netflix OSS and Spring CloudBuilding Distributed Systems with Netflix OSS and Spring Cloud
Building Distributed Systems with Netflix OSS and Spring Cloud
 
Pivotal Cloud Platform Roadshow: Sign Up for Pivotal Web Services
Pivotal Cloud Platform Roadshow: Sign Up for Pivotal Web ServicesPivotal Cloud Platform Roadshow: Sign Up for Pivotal Web Services
Pivotal Cloud Platform Roadshow: Sign Up for Pivotal Web Services
 
A Recovering Java Developer Learns to Go
A Recovering Java Developer Learns to GoA Recovering Java Developer Learns to Go
A Recovering Java Developer Learns to Go
 
Agile Development with OSGi
Agile Development with OSGiAgile Development with OSGi
Agile Development with OSGi
 
Cloud Foundry and Microservices: A Mutualistic Symbiotic Relationship
Cloud Foundry and Microservices: A Mutualistic Symbiotic RelationshipCloud Foundry and Microservices: A Mutualistic Symbiotic Relationship
Cloud Foundry and Microservices: A Mutualistic Symbiotic Relationship
 
It's the End of the Cloud as We Know It
It's the End of the Cloud as We Know ItIt's the End of the Cloud as We Know It
It's the End of the Cloud as We Know It
 
Functional solid
Functional solidFunctional solid
Functional solid
 
The Seven Wastes of Software Development
The Seven Wastes of Software DevelopmentThe Seven Wastes of Software Development
The Seven Wastes of Software Development
 
Information Sciences Solutions to Core Facility Problems at St. Jude Children...
Information Sciences Solutions to Core Facility Problems at St. Jude Children...Information Sciences Solutions to Core Facility Problems at St. Jude Children...
Information Sciences Solutions to Core Facility Problems at St. Jude Children...
 
Achieve Your Goals
Achieve Your GoalsAchieve Your Goals
Achieve Your Goals
 

Kürzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Kürzlich hochgeladen (20)

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
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...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
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
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
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...
 
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...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
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 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
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
 

Vert.x

  • 1. Vert.x: This ain’t your Dad’s Node! Matt Stine Tim Fox Enterprise Java/Cloud Consultant Father of Vert.x matt.stine@gmail.com http://mattstine.com Twitter: @mstine
  • 3.
  • 5. Ryan Dahl Father of Node.js How?!?!
  • 9.
  • 10.
  • 11.
  • 12. But Node has some shortcomings... 1. JavaScript! 2. Vertical Scaling 3. Interprocess Communication 4. Event Loop
  • 14. Problem #1: JavaScript Brendan Eich Father of JavaScript
  • 16. Solution #1: Polyglot Programming Neal Ford Father of Polyglot Programming http://memeagora.blogspot.com/2006/12/polyglot-programming.html
  • 17. Hello World in every Vert.x language!
  • 18. Java
  • 19.
  • 20. Ruby
  • 23.
  • 24. FUTURE Theoretically, any JVM language or language that compiles to a supported language (e.g. ClojureScript ➔ JavaScript)
  • 25. Problem #2: Vertical Scaling Lars Bak Father of V8
  • 27. Node: Up and Running Example 3-11: Using cluster to distribute work
  • 28. Solution #2: The JVM James Gosling Father of Java
  • 29. The Verticle - Unit of Deployment Verticle - Script/Java Class
  • 30. Vert.x Instance How it works it works it works it works How How How Event loop Event loop Event loop Event loop Event Loops App registers App registers App registers App registers trigger Events trigger Events trigger Events trigg Events handlers handlers handlers handlershandlers handlers handlers handlers • Handlers executed synchronously executed synchronously • Handlers executed synchronously executed synchronously • Handlers • Handlers – on a single threada single threada single threada single thread – on – on – on • Use handlersUse handlersUse handlersUse handlers to pass messages • to pass messages messages messages • to pass • to pass • Inter/intra application comms • Inter/intra application comms • Inter/intra application comms • Inter/intra application comms – EventBus with EventBus with EventBus with EventBus with messages – messages – messages – messages – Safe shared data structuresdata structuresdata structuresdata structures – Safe shared – Safe shared – Safe shared Verticle 9 9 9 Runtime.availableProcessors() == 4
  • 31. Vert.x Instance How it works it works it works it works How How How Event loop Event loop Event loop Event loop Event Loops App registers App registers App registers App registers trigger Events trigger Events trigger Events trigg Events handlers handlers handlers handlershandlers handlers handlers handlers • Handlers executed synchronously executed synchronously • Handlers executed synchronously executed synchronously • Handlers • Handlers – on a single threada single threada single threada single thread – on – on – on • Use handlersUse handlersUse handlersUse handlers to pass messages • to pass messages messages messages • to pass • to pass vertx run • Inter/intra application comms • Inter/intra application comms • Inter/intra application comms • Inter/intra application comms HelloWorld with EventBus with EventBus with EventBus with messages – EventBus – messages – messages – messages – Safe shared data structuresdata structuresdata structuresdata structures – Safe shared – Safe shared – Safe shared -instances 4 Verticle Verticle Verticle Verticle 9 9 9 Runtime.availableProcessors() == 4
  • 32. Concurrency • Verticle instance assigned thread/event loop. • Verticle instance ALWAYS executes on assigned thread. • Verticles have isolated classloaders and cannot share global state (static members, global variables, etc.) • Can write all code assuming single threading.
  • 33. Tony Hoare Father of CSP (http://dl.acm.org/citation.cfm? doid=359576.359585) Problem #3: Interprocess Communication
  • 34. Node.js Communication Options • TCP/UDP/UNIX Sockets • Redis Pub/Sub (http://redis.io/) • ZeroMQ (http://www.zeromq.org/) • Process Signaling/Cluster Module • Eventing Frameworks: Hook.io (dead), JS- Signals, Bean, etc. • Memcached • Etc...
  • 35. Solution #3.1: The Event Bus Alan Kay Father of Smalltalk
  • 36. How it works it works it works it works How How How Event loop Event loop Event loop Event loop App registers App registers App registers App registers trigger Events trigger Events trigger Events trigger Events handlers handlers handlers handlershandlers handlers handlers handlers • Handlers executed synchronously executed synchronously • Handlers executed synchronously executed synchronously • Handlers • Handlers – on a single threada single threada single threada single thread – on – on – on • Use handlersUse handlersUse handlersUse handlers to pass messages • to pass messages messages messages • to pass • to pass • Inter/intra application comms • Inter/intra application comms • Inter/intra application comms • Inter/intra application comms – EventBus with EventBus with EventBus with EventBus with messages – messages – messages – messages – Safe shared data structuresdata structuresdata structuresdata structures – Safe shared – Safe shared – Safe shared Verticle Verticle Verticle Verticle 9 9 9 9 Event Bus
  • 37. Addressing • Simply a String • Dot-style namespacing recommended • e.g. “messages.inbound.A”
  • 38. Handler Registration Handler X messages.inbound.A Handler Y Handler Z
  • 40. Pub/Sub Handler X Sender messages.inbound.A Handler Y Handler Z
  • 42. P2P Handler X Sender messages.inbound.A Handler Y Handler Z
  • 43. P2P
  • 45. Message Types • String • Primitives (int, long, short, float, double, ...) • Boxed Primitives • boolean/Boolean • org.vertx.java.core.json.JsonObject • org.vertx.java.core.buffer.Buffer
  • 46. Distributed Vert.x orks it works it works it works How How How How it works it works it works it works How How How How it works it works it works it works How How How Event loop Event loop Event loop Event loop Event loop Event loop Event loop Event loop Event loop Event loop Event loop Event loop rs App registers App registers App registers trigger Events trigger Events trigger Events trigger registers App registers trigger Events trigger Events trigger Events trigger registers App registers trigger Events trigger Events trigger Events App registers App registers App Events App registers App registers App Events handlers handlers handlershandlers handlers handlers handlers handlers handlers handlers handlershandlers handlers handlers handlers handlers handlers handlers handlershandlers handlers handlers executed synchronously executed synchronously • Handlers executed synchronously executed synchronously • Handlers • Handlers • Handlers executed synchronously executed synchronously • Handlers executed synchronously executed synchronously • Handlers • Handlers • Handlers executed synchronously executed synchronously • Handlers executed synchronously executed synchronously • Handlers • Handlers le threada single threada single threada single thread – on – on – on – on a single threada single threada single threada single thread – on – on – on – on a single threada single threada single threada single thread – on – on – on ersUsepass messages messages messages messages handlersUsepass messages messages messages messages handlersUse handlersUsepass messages messages messages • to handlersUse handlersUsepass • to pass • to handlers to pass • Use • to handlersUse handlersUsepass • to pass • to handlers to pass • Use • to pass messages • to handlersUse handlers to pass • to pass application comms • Inter/intra application comms • Inter/intra application comms • Inter/intra application comms• Inter/intra application comms • Inter/intra application comms • Inter/intra application comms • Inter/intra application comms Inter/intra application comms • • Inter/intra application comms • Inter/intra application comms • Inter/intra application comms s with EventBus with EventBus with EventBus with messages – messages – messages – messages – EventBus with EventBus with EventBus with EventBus with messages – messages – messages – messages – EventBus with EventBus with EventBus with EventBus with messages – messages – messages – messages red data structuresdata structuresdata structuresdata structures – Safe shared – Safe shared – Safe shared – Safe shared data structuresdata structuresdata structuresdata structures – Safe shared – Safe shared – Safe shared – Safe shared data structuresdata structuresdata structuresdata structures – Safe shared – Safe shared – Safe shared Verticle Verticle Verticle 9 Verticle9 9 Verticle 9 Verticle Verticle 9 Verticle 9 9 Verticle 9 Verticle Verticle 9 Verticle 9 9 Event Bus
  • 47. Into the Browser! orks it works it works it works How How How How it works it works it works it works How How How Event loop Event loop Event loop Event loop Event loop Event loop Event loop Event loop rs App registers App registers App registers trigger Events trigger Events trigger Events trigger registers App registers trigger Events trigger Events trigger Events trigger Events App registers App registers App Events handlers handlers handlershandlers handlers handlers handlers handlers handlers handlers handlershandlers handlers handlers handlers executed synchronously executed synchronously • Handlers executed synchronously executed synchronously • Handlers • Handlers • Handlers executed synchronously executed synchronously • Handlers executed synchronously executed synchronously • Handlers • Handlers le threada single threada single threada single thread – on – on – on – on a single threada single threada single threada single thread – on – on – on ersUsepass messages messages messages messages handlersUsepass messages messages messages messages • to handlersUse handlersUsepass • to pass • to handlers to pass • Use • to handlersUse handlersUsepass • to pass • to handlers to pass application comms • Inter/intra application comms • Inter/intra application comms • Inter/intra application comms• Inter/intra application comms • Inter/intra application comms • Inter/intra application comms • Inter/intra application comms s with EventBus with EventBus with EventBus with messages – messages – messages – messages – EventBus with EventBus with EventBus with EventBus with messages – messages – messages – messages red data structuresdata structuresdata structuresdata structures – Safe shared – Safe shared – Safe shared – Safe shared data structuresdata structuresdata structuresdata structures – Safe shared – Safe shared – Safe shared Verticle Verticle Verticle 9 Verticle9 9 Verticle 9 Verticle Verticle 9 Verticle 9 9 9 SockJS Bridge Event Bus
  • 50. Demo
  • 51. Solution #3.2: Shared Immutable State Rich Hickey Father of Clojure
  • 53. MessageAI L Passing? F
  • 54. Shared state only dangerous if it is MUTABLE!
  • 55. Vert.x Shared State • SharedData Object (vertx.sharedData()) • collection of java.util.concurrent.ConcurrentMap<K,V> • collection of java.util.Set<E> (backed by ConcurrentMap) • Elements MUST be immutable values (well, sort of...) • Currently only available within a Vertx. instance, not across a cluster.
  • 56. Allowed Values • Strings • Boxed Primitives •byte[] R ! •org.vertx.java.core.buffer.Buffer • Implementors of G E Shareable AN org.vertx.java.core.shareddata. D
  • 59. Problem #4: The Event Loop Douglas Schmidt Father of the Reactor Pattern
  • 60. Reactor w it works Pattern Review Event loop Application ...events pp registers registers Events t trigger handlers handl handlers... handlers. Event Loop andlers executed synchronously on a single thread se handlers to pass messages
  • 61. Reactor Pattern Review • Single thread / single event loop • EVERYTHING runs on it • You MUST NOT block the event loop
  • 62. Reactor Pattern Problems • Some work is naturally blocking: • Intensive data crunching • 3rd-party blocking API’s (e.g. JDBC) • Pure reactor (e.g. Node.js) is not a good fit for this kind of work!
  • 63. Solution #4: Worker Verticles Carl Hewitt Father of the Actor Model
  • 64. Worker Verticles • Not assigned a Vert.x event loop thread • Executes on background thread pool • Never executed concurrently by more than one thread • Not allowed to use TCP or HTTP clients/ servers • Communicate using the event bus • Should be kept to a minimum
  • 65. The “Multi-reactor” How it works it works it works it works How How How Event loop Event loop Event loop Event loop BG BG App registers App registers App registers App registers trigger Events trigger Events trigger Events trigger Events handlers handlers handlers handlershandlers handlers Pool handlers Pool handlers • Handlers executed synchronously executed synchronously • Handlers executed synchronously executed synchronously • Handlers • Handlers – on a single threada single threada single threada single thread – on – on – on • Use handlersUse handlersUse handlersUse handlers to pass messages • to pass messages messages messages • to pass • to pass • Inter/intra application comms • Inter/intra application comms • Inter/intra application comms • Inter/intra application comms – EventBus with EventBus with EventBus with EventBus with messages – messages – messages – messages – Safe shared data structuresdata structuresdata structuresdata structures – Safe shared – Safe shared – Safe shared Worker Worker Verticle Verticle Verticle Verticle Verticle Verticle 9 9 9 9 Event Bus
  • 66.
  • 67.
  • 68. Problem/Solution Summary • Node.js compels the use of JavaScript • Vert.x is Polyglot • Node.js is inherently single-threaded • Vert.x leverages the multi-threaded JVM
  • 69. Problem/Solution Summary • Node.js doesn’t help much w/ interprocess communication • Vert.x features a distributed event bus which reaches all the way into the browser • Node.js requires all code to run on the event loop • Vert.x features background workers that allow blocking work to be done off of the event loops
  • 70. Other Goodies • Growing Module • TCP/SSL servers/clients Repository • HTTP/HTTPS servers/ clients • web server • persistors (Mongo, • WebSockets support JDBC, ...) • SockJS support • work queue • Timers • authentication • Buffers manager • Streams and Pumps • session manager • Routing • Socket.IO • Asynchronous File I/O
  • 72. Get Involved! • Google Group: http://groups.google.com/ group/vertx • GitHub: https://github.com/vert-x/vert.x • IRC: irc://freenode.net/vertx • Needs: • language implementations • modules (esp. persistence, security, ...) • examples/blogs/documentation help
  • 73. Vert.x: This ain’t your Dad’s Node! Matt Stine Enterprise Java/Cloud Consultant Please fill out an evaluation: matt.stine@gmail.com http://mattstine.com http://speakerrate.com/talks/16821 Twitter: @mstine
  • 74. Image Credits • Tim Fox: https://twitter.com/timfox • BSOD Phone: http://www.flickr.com/photos/markhillary/3413357033 • V8: http://www.flickr.com/photos/gorbould/3479298062 • Ryan Dahl: http://www.flickr.com/photos/franksvalli/5163205409 • Shortcomings: http://www.flickr.com/photos/hendricksphotos/3340896056 • Brendan Eich: http://www.flickr.com/photos/equanimity/4055148344 • Neal Ford: http://nealford.com/images/Neal-2012-headshot.jpg • Lars Bak: http://www.flickr.com/photos/niallkennedy/2822229099 • James Gosling: http://www.flickr.com/photos/skrb/2499736195 • Tony Hoare: http://www.flickr.com/photos/adewale_oshineye/3687557065 • Alan Kay: http://www.flickr.com/photos/mwichary/3010026816 • Rich Hickey: http://www.flickr.com/photos/hlship/3603090614 • Douglas Schmidt: http://www.cs.wustl.edu/~schmidt/gifs/SchmidtD.jpg • Carl Hewitt: http://www.flickr.com/photos/jeanbaptisteparis/3098594954