SlideShare ist ein Scribd-Unternehmen logo
1 von 45
vert.x
 Effortless asynchronous application
development for the modern web and
              enterprise
Stuart Williams

              'Pid'
     Consulting Architect
SpringSource Division of VMware*

        vert.x committer

             @pidster



     * Correct at time of writing
What is vert.x?
•
    Polyglot
•
    Simple
•
    Scalable
•
    Asynchronous
•
    Concurrent
Polyglot
Write application components in:
•
    JavaScript (+CoffeeScript +AngularJS)
•
    Ruby
•
    Python
•
    Groovy
•
    Java
Mix and match several programming languages
in a single app.
Simple
•
    ...without being simplistic
•
    Create real applications in just a few lines of code
•
    No XML config
Scalable
•
    Linear horizontal scale
•
    Uses message passing
•
    Automatic load-balancing
•
    Efficiently utilise your server cores
Asynchronous
•
    NIO
•
    Handlers
•
    EventBus
•
    FileSystem
•
    WebSockets
•
    SockJS
SockJS
●
  Handles the communication between the browser
  and the server.
●
  Provides a websocket-like API in client-side JS
●
  Works when websockets not available
●
  JSON-Polling, XHR-Polling/Streaming, etc
●
  Similar in some ways to socket.io
●
  More info at http://sockjs.org
Concurrency Model
●
  A verticle instance is single-threaded.
●
  Move away from 'Java-style' multi-threaded
  concurrency
●
  No more synchronized, volatile or locking
●
  Wave goodbye to many race conditions
Threading Model – Event Loops
●
  vert.x implements the Multi-Reactor Pattern
●
  An event loop is an OS thread
●
  Handles events for many handlers
●
  vert.x has multiple event loops – typically one per
  core.
●
  Don't block the event loop!
Event Loop != Silver Bullet
●
  Event loops not the best fit for all types of stuff
●
  Long running calculations (Fibonacci anyone?)
●
  Using blocking APIs – e.g. JDBC
●
  Most traditional Java libs have blocking APIs
●
  … how do we leverage them?
Hybrid Threading Model
●
  Don't force everything to run on an event loop
●
  Worker verticles can block
●
  Communicate with other verticles by message
  passing.
●
  Allows us to leverage the huge ecosystem of
  blocking Java libs
Real-time Web Applications
●
  Modern definition of real-time
●
  Event bus key technology for real-time web
  applications
●
  Focus on sending messages to server
  components or other browser nodes
●
  Mobile applications, online games
●
  Use vert.x with any JS toolkit.
Examples
JavaScript
load('vertx.js’)

vertx.createHttpServer().requestHandler(function(req) {
    var file = req.path === '/' ? 'index.html' : req.path;
    req.response.sendFile('webroot/' + file);
}).listen(8080)
Ruby
require "vertx"

Vertx::HttpServer.new.request_handler do |req|
  file = req.uri == "/" ? "index.html" : req.uri
  req.response.send_file "webroot/#{file}"
end.listen(8080)
Python
import vertx

server = vertx.create_http_server()

@server.request_handler
def request_handler(req):
  file = "index.html" if req.uri == "/" else req.uri
  req.response.send_file("webroot/%s"%file)
server.listen(8080)
Groovy
vertx.createHttpServer().requestHandler { req ->
    def file = req.uri == "/" ? "index.html" : req.uri
    req.response.sendFile "webroot/$file"
}.listen(8080)
Java
import org.vertx.java.core.Handler;
import org.vertx.java.core.http.HttpServerRequest;
import org.vertx.java.deploy.Verticle;
public class Server extends Verticle {
    public void start() {
        vertx.createHttpServer().requestHandler(new Handler<HttpServerRequest>(){
          public void handle(HttpServerRequest req) {
              String file = req.path.equals("/") ? "index.html" : req.path;
              req.response.sendFile("webroot/" + file);
          }
        }).listen(8080);
    }
}
Architecture
Classloaders & Messages
Key Dependencies
•
    Java 7
•
    Netty
•
    Hazelcast
•
    Jackson
•
    JRuby
•
    Jython
•
    Rhino
Key API Methods
vertx.createXXXServer
vertx.createXXXClient
vertx.fileSystem
vertx.sharedData
vertx.eventBus
vertx.setPeriodic
vertx.setTimer
Servers
•
    NetServer
•
    HttpServer
    –
        RouteMatcher
    –
        ServerWebSocket
•
    SockJSServer
Clients
•
    NetClient
•
    HttpClient
    –
        WebSocket
•
    SockJSSocket
EventBus
eventBus.send(‘address’, message, replyHandler)
eventBus.publish(‘address’, message)

•
    EventBus Bridge – send messages direct to JavaScript in
    web browsers
•
    Messages are strongly typed in Java
•
    JSON in JavaScript
•
    Hash in Python, Ruby
Cluster
•
    Hazelcast manages event bus address map and
    cluster membership
•
    Explain cache, listeners
•
    vert.x NetServer & NetClient used for comms
•
    Fully configurable network ports
•
    Use SSL for security
vert.x Applications
Application Components

Init Verticle                      Server Verticle



                                   EventBus Modules



                Worker Modules



                8                    20
      Event Loop                 Worker Pool
launcher.groovy
var config = [
  address: "org.pidster.foobar.control",
  port: 8081
]
vertx.deployModule('org.pidster.foobar-v1.0', config, 1, { did->
  println “deployed with id: $did”
})

def stop() {
  // stop & clean up
}
Modules
•
    Authentication Manager
•
    Form Upload
•
    JDBC Persistor
•
    Mailer
•
    Mongo Persistor
•
    Session Manager
•
    Web Server
•
    Work Queue
•
    AMQP
mod-web-server

var config = [
  web_root: <web_root>,
  port, <port>,
  ssl: <ssl>,
  key_store_password: <key_store_password>,
  key_store_path: <key_store_path>,
]

vertx.deployModule('vertx.web-server-v1.0', config, 1, { did->
  // deployed
})
web + EventBusBridge

var config = [
  web_root: <web_root>,
  port, <port>,
  bridge: true
]

vertx.deployModule('vertx.web-server-v1.0', config, 1, { did->
  vertx.registerHandler('some.address', { msg->
    println “msg: $msg”
  }
})
Module Structure
•
    Simple structure
•
    Optional lib dir
•
    Lazy installation
•
    Modules can include other modules
•
    mod.json
{
 “main”:”org.pidster.jdbc.Main”,
 “worker”: “true”,
 “includes: “org.pidster-foobar-v1.0”
}
Developing & Testing
•
    Gradle (or Maven (or Ant!))
•
    Use a verticle script to launch tests
•
    Setup Classloader scope
•
    vertx-junit-annotations

src/main/groovy
src/test/groovy
src/vertxInteg/groovy
Best Practice
•
    Verticle script to manage lifecycle
•
    Define configuration in JSON
•
    Compose from modules
•
    Never block the event loop!
What’s next?
Languages
•
    Languages as modules
•
    Lazy installation
•
    Scala
•
    Clojure
Management
•
    JMX API
•
    Publish metrics on EventBus in JSON
•
    Configurable sample time & filters
•
    GUI
•
    github.com/swilliams-vmw/mod-management
Developers & API
•
    IDE support
•
    Build config and plugins
•
    Better, easier testing
•
    More examples
•
    Promises API?
•
    Direct-style API using continuations?
Project
Community

•
    vert.x is Open Source
•
    Active community
•
    Contributions welcome
•
    Module repository is growing
Project
•
    http://vertx.io
•
    @timfox – project lead
•
    @pidster – project lurker
•
    https://github.com/vert-x
•
    Google Group: vertx
Summary
•
    Polyglot – use the languages you want
•
    Simple concurrency – wave goodbye to most
    race conditions
•
    Leverage existing Java library ecosystem
•
    Powerful distributed event bus which spans
    client and server
•
    Flexible module system
Questions?

Weitere ähnliche Inhalte

Was ist angesagt?

Spicing up JMX with Jolokia (Devoxx 2014)
Spicing up JMX with Jolokia (Devoxx 2014)Spicing up JMX with Jolokia (Devoxx 2014)
Spicing up JMX with Jolokia (Devoxx 2014)roland.huss
 
Node.js, toy or power tool?
Node.js, toy or power tool?Node.js, toy or power tool?
Node.js, toy or power tool?Ovidiu Dimulescu
 
KubeFuse - A File-System for Kubernetes
KubeFuse - A File-System for KubernetesKubeFuse - A File-System for Kubernetes
KubeFuse - A File-System for KubernetesBart Spaans
 
Fabric8 - Being devOps doesn't suck anymore
Fabric8 - Being devOps doesn't suck anymoreFabric8 - Being devOps doesn't suck anymore
Fabric8 - Being devOps doesn't suck anymoreHenryk Konsek
 
Introduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azureIntroduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azureColin Mackay
 
Distributed Locking in Kubernetes
Distributed Locking in KubernetesDistributed Locking in Kubernetes
Distributed Locking in KubernetesRafał Leszko
 
Architectural caching patterns for kubernetes
Architectural caching patterns for kubernetesArchitectural caching patterns for kubernetes
Architectural caching patterns for kubernetesRafał Leszko
 
I Just Want to Run My Code: Waypoint, Nomad, and Other Things
I Just Want to Run My Code: Waypoint, Nomad, and Other ThingsI Just Want to Run My Code: Waypoint, Nomad, and Other Things
I Just Want to Run My Code: Waypoint, Nomad, and Other ThingsMichael Lange
 
KubeCon 2017: Kubernetes from Dev to Prod
KubeCon 2017: Kubernetes from Dev to ProdKubeCon 2017: Kubernetes from Dev to Prod
KubeCon 2017: Kubernetes from Dev to ProdSubhas Dandapani
 
K8s storage-glusterfs-20180210
K8s storage-glusterfs-20180210K8s storage-glusterfs-20180210
K8s storage-glusterfs-20180210Che-Chia Chang
 
Kubernetes Architecture and Introduction – Paris Kubernetes Meetup
Kubernetes Architecture and Introduction – Paris Kubernetes MeetupKubernetes Architecture and Introduction – Paris Kubernetes Meetup
Kubernetes Architecture and Introduction – Paris Kubernetes MeetupStefan Schimanski
 
A Performance Comparison of Container-based Virtualization Systems for MapRed...
A Performance Comparison of Container-based Virtualization Systems for MapRed...A Performance Comparison of Container-based Virtualization Systems for MapRed...
A Performance Comparison of Container-based Virtualization Systems for MapRed...Marcelo Veiga Neves
 
Threads Needles Stacks Heaps - Java edition
Threads Needles Stacks Heaps - Java editionThreads Needles Stacks Heaps - Java edition
Threads Needles Stacks Heaps - Java editionOvidiu Dimulescu
 
Pharo Update
Pharo Update Pharo Update
Pharo Update ESUG
 
Introducing OpenStack for Beginners
Introducing OpenStack for Beginners Introducing OpenStack for Beginners
Introducing OpenStack for Beginners openstackindia
 

Was ist angesagt? (20)

Spicing up JMX with Jolokia (Devoxx 2014)
Spicing up JMX with Jolokia (Devoxx 2014)Spicing up JMX with Jolokia (Devoxx 2014)
Spicing up JMX with Jolokia (Devoxx 2014)
 
Node.js, toy or power tool?
Node.js, toy or power tool?Node.js, toy or power tool?
Node.js, toy or power tool?
 
KubeFuse - A File-System for Kubernetes
KubeFuse - A File-System for KubernetesKubeFuse - A File-System for Kubernetes
KubeFuse - A File-System for Kubernetes
 
Container orchestration
Container orchestrationContainer orchestration
Container orchestration
 
Fabric8 - Being devOps doesn't suck anymore
Fabric8 - Being devOps doesn't suck anymoreFabric8 - Being devOps doesn't suck anymore
Fabric8 - Being devOps doesn't suck anymore
 
Introduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azureIntroduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azure
 
JavaCro'15 - Docker, Kubernetes and Jube - a new cloud architecture - Aleš Ju...
JavaCro'15 - Docker, Kubernetes and Jube - a new cloud architecture - Aleš Ju...JavaCro'15 - Docker, Kubernetes and Jube - a new cloud architecture - Aleš Ju...
JavaCro'15 - Docker, Kubernetes and Jube - a new cloud architecture - Aleš Ju...
 
Distributed Locking in Kubernetes
Distributed Locking in KubernetesDistributed Locking in Kubernetes
Distributed Locking in Kubernetes
 
Architectural caching patterns for kubernetes
Architectural caching patterns for kubernetesArchitectural caching patterns for kubernetes
Architectural caching patterns for kubernetes
 
I Just Want to Run My Code: Waypoint, Nomad, and Other Things
I Just Want to Run My Code: Waypoint, Nomad, and Other ThingsI Just Want to Run My Code: Waypoint, Nomad, and Other Things
I Just Want to Run My Code: Waypoint, Nomad, and Other Things
 
KubeCon 2017: Kubernetes from Dev to Prod
KubeCon 2017: Kubernetes from Dev to ProdKubeCon 2017: Kubernetes from Dev to Prod
KubeCon 2017: Kubernetes from Dev to Prod
 
K8s storage-glusterfs-20180210
K8s storage-glusterfs-20180210K8s storage-glusterfs-20180210
K8s storage-glusterfs-20180210
 
Flocker
FlockerFlocker
Flocker
 
OpenStack Storage Overview
OpenStack Storage OverviewOpenStack Storage Overview
OpenStack Storage Overview
 
Kubernetes Architecture and Introduction – Paris Kubernetes Meetup
Kubernetes Architecture and Introduction – Paris Kubernetes MeetupKubernetes Architecture and Introduction – Paris Kubernetes Meetup
Kubernetes Architecture and Introduction – Paris Kubernetes Meetup
 
A Performance Comparison of Container-based Virtualization Systems for MapRed...
A Performance Comparison of Container-based Virtualization Systems for MapRed...A Performance Comparison of Container-based Virtualization Systems for MapRed...
A Performance Comparison of Container-based Virtualization Systems for MapRed...
 
Threads Needles Stacks Heaps - Java edition
Threads Needles Stacks Heaps - Java editionThreads Needles Stacks Heaps - Java edition
Threads Needles Stacks Heaps - Java edition
 
Pharo Update
Pharo Update Pharo Update
Pharo Update
 
Intro to Kubernetes
Intro to KubernetesIntro to Kubernetes
Intro to Kubernetes
 
Introducing OpenStack for Beginners
Introducing OpenStack for Beginners Introducing OpenStack for Beginners
Introducing OpenStack for Beginners
 

Ähnlich wie Groovy & Grails eXchange 2012 vert.x presentation

introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.jsorkaplan
 
End-to-end HTML5 APIs - The Geek Gathering 2013
End-to-end HTML5 APIs - The Geek Gathering 2013End-to-end HTML5 APIs - The Geek Gathering 2013
End-to-end HTML5 APIs - The Geek Gathering 2013Alexandre Morgaut
 
Node.js 101 with Rami Sayar
Node.js 101 with Rami SayarNode.js 101 with Rami Sayar
Node.js 101 with Rami SayarFITC
 
Node.JS and WebSockets with Faye
Node.JS and WebSockets with FayeNode.JS and WebSockets with Faye
Node.JS and WebSockets with FayeMatjaž Lipuš
 
FITC - Node.js 101
FITC - Node.js 101FITC - Node.js 101
FITC - Node.js 101Rami Sayar
 
Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsasync_io
 
Node.js: The What, The How and The When
Node.js: The What, The How and The WhenNode.js: The What, The How and The When
Node.js: The What, The How and The WhenFITC
 
End-to-end W3C APIs - tpac 2012
End-to-end W3C APIs - tpac 2012End-to-end W3C APIs - tpac 2012
End-to-end W3C APIs - tpac 2012Alexandre Morgaut
 
Is OSGi modularity always worth it?
Is OSGi modularity always worth it?Is OSGi modularity always worth it?
Is OSGi modularity always worth it?glynnormington
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)slire
 
Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Ran Mizrahi
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Ran Mizrahi
 
Building APIs with NodeJS on Microsoft Azure Websites - Redmond
Building APIs with NodeJS on Microsoft Azure Websites - RedmondBuilding APIs with NodeJS on Microsoft Azure Websites - Redmond
Building APIs with NodeJS on Microsoft Azure Websites - RedmondRick G. Garibay
 
Node.js to the rescue
Node.js to the rescueNode.js to the rescue
Node.js to the rescueMarko Heijnen
 
Introduction to node.js by jiban
Introduction to node.js by jibanIntroduction to node.js by jiban
Introduction to node.js by jibanJibanananda Sana
 

Ähnlich wie Groovy & Grails eXchange 2012 vert.x presentation (20)

introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
End-to-end HTML5 APIs - The Geek Gathering 2013
End-to-end HTML5 APIs - The Geek Gathering 2013End-to-end HTML5 APIs - The Geek Gathering 2013
End-to-end HTML5 APIs - The Geek Gathering 2013
 
Node.js 101 with Rami Sayar
Node.js 101 with Rami SayarNode.js 101 with Rami Sayar
Node.js 101 with Rami Sayar
 
Node.JS and WebSockets with Faye
Node.JS and WebSockets with FayeNode.JS and WebSockets with Faye
Node.JS and WebSockets with Faye
 
FITC - Node.js 101
FITC - Node.js 101FITC - Node.js 101
FITC - Node.js 101
 
signalr
signalrsignalr
signalr
 
Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.js
 
Node.js: The What, The How and The When
Node.js: The What, The How and The WhenNode.js: The What, The How and The When
Node.js: The What, The How and The When
 
End-to-end W3C APIs - tpac 2012
End-to-end W3C APIs - tpac 2012End-to-end W3C APIs - tpac 2012
End-to-end W3C APIs - tpac 2012
 
Is OSGi modularity always worth it?
Is OSGi modularity always worth it?Is OSGi modularity always worth it?
Is OSGi modularity always worth it?
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
 
Node.js on Azure
Node.js on AzureNode.js on Azure
Node.js on Azure
 
Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)
 
20120306 dublin js
20120306 dublin js20120306 dublin js
20120306 dublin js
 
Building APIs with NodeJS on Microsoft Azure Websites - Redmond
Building APIs with NodeJS on Microsoft Azure Websites - RedmondBuilding APIs with NodeJS on Microsoft Azure Websites - Redmond
Building APIs with NodeJS on Microsoft Azure Websites - Redmond
 
Node.js to the rescue
Node.js to the rescueNode.js to the rescue
Node.js to the rescue
 
Introduction to node.js by jiban
Introduction to node.js by jibanIntroduction to node.js by jiban
Introduction to node.js by jiban
 
Nodejs
NodejsNodejs
Nodejs
 
Nodejs web,db,hosting
Nodejs web,db,hostingNodejs web,db,hosting
Nodejs web,db,hosting
 

Kürzlich hochgeladen

Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
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 FMESafe Software
 
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, ...apidays
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
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.pdfsudhanshuwaghmare1
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
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 Takeoffsammart93
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 

Kürzlich hochgeladen (20)

Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
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
 
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, ...
 
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
 
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
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
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 New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 

Groovy & Grails eXchange 2012 vert.x presentation

  • 1. vert.x Effortless asynchronous application development for the modern web and enterprise
  • 2. Stuart Williams 'Pid' Consulting Architect SpringSource Division of VMware* vert.x committer @pidster * Correct at time of writing
  • 3. What is vert.x? • Polyglot • Simple • Scalable • Asynchronous • Concurrent
  • 4. Polyglot Write application components in: • JavaScript (+CoffeeScript +AngularJS) • Ruby • Python • Groovy • Java Mix and match several programming languages in a single app.
  • 5. Simple • ...without being simplistic • Create real applications in just a few lines of code • No XML config
  • 6. Scalable • Linear horizontal scale • Uses message passing • Automatic load-balancing • Efficiently utilise your server cores
  • 7. Asynchronous • NIO • Handlers • EventBus • FileSystem • WebSockets • SockJS
  • 8. SockJS ● Handles the communication between the browser and the server. ● Provides a websocket-like API in client-side JS ● Works when websockets not available ● JSON-Polling, XHR-Polling/Streaming, etc ● Similar in some ways to socket.io ● More info at http://sockjs.org
  • 9. Concurrency Model ● A verticle instance is single-threaded. ● Move away from 'Java-style' multi-threaded concurrency ● No more synchronized, volatile or locking ● Wave goodbye to many race conditions
  • 10. Threading Model – Event Loops ● vert.x implements the Multi-Reactor Pattern ● An event loop is an OS thread ● Handles events for many handlers ● vert.x has multiple event loops – typically one per core. ● Don't block the event loop!
  • 11. Event Loop != Silver Bullet ● Event loops not the best fit for all types of stuff ● Long running calculations (Fibonacci anyone?) ● Using blocking APIs – e.g. JDBC ● Most traditional Java libs have blocking APIs ● … how do we leverage them?
  • 12. Hybrid Threading Model ● Don't force everything to run on an event loop ● Worker verticles can block ● Communicate with other verticles by message passing. ● Allows us to leverage the huge ecosystem of blocking Java libs
  • 13. Real-time Web Applications ● Modern definition of real-time ● Event bus key technology for real-time web applications ● Focus on sending messages to server components or other browser nodes ● Mobile applications, online games ● Use vert.x with any JS toolkit.
  • 15. JavaScript load('vertx.js’) vertx.createHttpServer().requestHandler(function(req) { var file = req.path === '/' ? 'index.html' : req.path; req.response.sendFile('webroot/' + file); }).listen(8080)
  • 16. Ruby require "vertx" Vertx::HttpServer.new.request_handler do |req| file = req.uri == "/" ? "index.html" : req.uri req.response.send_file "webroot/#{file}" end.listen(8080)
  • 17. Python import vertx server = vertx.create_http_server() @server.request_handler def request_handler(req): file = "index.html" if req.uri == "/" else req.uri req.response.send_file("webroot/%s"%file) server.listen(8080)
  • 18. Groovy vertx.createHttpServer().requestHandler { req -> def file = req.uri == "/" ? "index.html" : req.uri req.response.sendFile "webroot/$file" }.listen(8080)
  • 19. Java import org.vertx.java.core.Handler; import org.vertx.java.core.http.HttpServerRequest; import org.vertx.java.deploy.Verticle; public class Server extends Verticle { public void start() { vertx.createHttpServer().requestHandler(new Handler<HttpServerRequest>(){ public void handle(HttpServerRequest req) { String file = req.path.equals("/") ? "index.html" : req.path; req.response.sendFile("webroot/" + file); } }).listen(8080); } }
  • 22. Key Dependencies • Java 7 • Netty • Hazelcast • Jackson • JRuby • Jython • Rhino
  • 24. Servers • NetServer • HttpServer – RouteMatcher – ServerWebSocket • SockJSServer
  • 25. Clients • NetClient • HttpClient – WebSocket • SockJSSocket
  • 26. EventBus eventBus.send(‘address’, message, replyHandler) eventBus.publish(‘address’, message) • EventBus Bridge – send messages direct to JavaScript in web browsers • Messages are strongly typed in Java • JSON in JavaScript • Hash in Python, Ruby
  • 27. Cluster • Hazelcast manages event bus address map and cluster membership • Explain cache, listeners • vert.x NetServer & NetClient used for comms • Fully configurable network ports • Use SSL for security
  • 29. Application Components Init Verticle Server Verticle EventBus Modules Worker Modules 8 20 Event Loop Worker Pool
  • 30. launcher.groovy var config = [ address: "org.pidster.foobar.control", port: 8081 ] vertx.deployModule('org.pidster.foobar-v1.0', config, 1, { did-> println “deployed with id: $did” }) def stop() { // stop & clean up }
  • 31. Modules • Authentication Manager • Form Upload • JDBC Persistor • Mailer • Mongo Persistor • Session Manager • Web Server • Work Queue • AMQP
  • 32. mod-web-server var config = [ web_root: <web_root>, port, <port>, ssl: <ssl>, key_store_password: <key_store_password>, key_store_path: <key_store_path>, ] vertx.deployModule('vertx.web-server-v1.0', config, 1, { did-> // deployed })
  • 33. web + EventBusBridge var config = [ web_root: <web_root>, port, <port>, bridge: true ] vertx.deployModule('vertx.web-server-v1.0', config, 1, { did-> vertx.registerHandler('some.address', { msg-> println “msg: $msg” } })
  • 34. Module Structure • Simple structure • Optional lib dir • Lazy installation • Modules can include other modules • mod.json { “main”:”org.pidster.jdbc.Main”, “worker”: “true”, “includes: “org.pidster-foobar-v1.0” }
  • 35. Developing & Testing • Gradle (or Maven (or Ant!)) • Use a verticle script to launch tests • Setup Classloader scope • vertx-junit-annotations src/main/groovy src/test/groovy src/vertxInteg/groovy
  • 36. Best Practice • Verticle script to manage lifecycle • Define configuration in JSON • Compose from modules • Never block the event loop!
  • 38. Languages • Languages as modules • Lazy installation • Scala • Clojure
  • 39. Management • JMX API • Publish metrics on EventBus in JSON • Configurable sample time & filters • GUI • github.com/swilliams-vmw/mod-management
  • 40. Developers & API • IDE support • Build config and plugins • Better, easier testing • More examples • Promises API? • Direct-style API using continuations?
  • 42. Community • vert.x is Open Source • Active community • Contributions welcome • Module repository is growing
  • 43. Project • http://vertx.io • @timfox – project lead • @pidster – project lurker • https://github.com/vert-x • Google Group: vertx
  • 44. Summary • Polyglot – use the languages you want • Simple concurrency – wave goodbye to most race conditions • Leverage existing Java library ecosystem • Powerful distributed event bus which spans client and server • Flexible module system