SlideShare a Scribd company logo
vert.x v3
high performance
polyglot application toolkit
Hello!
Bartek Zdanowski
@bartekzdanowski
2
Hello!
developer @
vertx lover
father and husband :)
3
vert.x
4
vert.x
5
Invented by Tim Fox as Node.x
24 June 2015 - released v3
still it’s very hot :D
vert.x buzzwords
simple embeddable toolkit
threadSafe concurrent
asynchronous eventDriven reactive
eventBus scalable
polyglot
6
vert.x buzzwords
fun
7
the problem
8
the problem
number of mobile users raises
2,1 bln in 2012 -> 7 bln in 2018
Internet of things - 30 bln in 2020!
IPv4 is exhausted
IPv6 is already ready for all of them
9
the problem
traditional synchronous approach
■one thread handles one task
■thread is waiting for job to finish
■whole queue of tasks waits
10
the problem
traditional synchronous approach
■synchronous code
■scalability problem
■lots of threads
■concurrency that no-one understands ;)
11
the problem
12
Tomcat: 200 threads = 200 connections
rest of incoming connections must wait*…
*okay, now you can do nonblocking in Tomcat
https://tomcat.apache.org/tomcat-7.0-doc/aio.html
the problem
13
thread pools
the problem
14
thread pools
the problem
big thread pools are evil
synchronous code is even more evil
concurrency is very hard
synchronous == blocking
15
the solution
16
the solution
17
thread pools
the solution
18
1 task = series of loosely coupled events
event that informs that new job/data is
waiting
the solution
19
program should release thread instead of
waiting for operation (I/O) to be finished
use non-blocking IO (NIO)
the solution
20
asynchronous
event driven
the solution
21
vert.x
22
dispatcherhandlers
thread pool
reactor
vert.x
23
handlers
thread pool
thread-1
handler 1
handler 2
vert.x
24
thread pool == double cores count
actor like model
some code
25
26
public class HelloVerticle extends AbstractVerticle {
@Override
public void start() {
LoggerFactory.getLogger(getClass()).info(
"Hello vert.x");
}
}
27
public static final String CONSUMER_ADDRESS =
"consumer.address";
public void start() {
vertx.eventBus().consumer(CONSUMER_ADDRESS,
new Handler<Message<String>>() {
public void handle(Message<String> message) {
logger.info("Got message:" + message.body());
}
});
}
//Java < 8
28
public static final String CONSUMER_ADDRESS =
"consumer.address";
public void start() {
vertx.eventBus().consumer(CONSUMER_ADDRESS,
message -> {
logger.info("Got message: " + message.body());
});
}
//Java 8 Lambdas FTW!
threadsafe code
29
threadsafe
30
class MyService {
public synchronized Result doSomething(Data data) {
//do some critical stuff
}
}
threadsafe
only when one thread!
31
class MyService {
public synchronized Result doSomething(Data data) {
//do some critical stuff
}
}
threadsafe
particular verticle runs in one thread!
32
33
verticle
34
basic deployment unit
actor-like model (akka similarity)
always run in the same thread
can have many instances
verticle
verticle
threadsafe code
■verticle instance - always the same thread
■can have separated classloaders for each
verticle instance
35
verticle
threadsafe code
■event bus separates threads
■shared data: maps, counters, locks
36
verticle
types
■standard
■worker
■multi-threaded worker
37
let’s code!
38
■hello world vert.x - first verticle
■deploying other verticles
●one instance
●many instances
●other after successful deployment
●deployment options
●passing config
39
let’s code!
S1
■running from IDE
■running from command line
●java -jar
●vertx run
40
let’s code!
S1
41
eventBus
42
eventBus
43
eventBus
44
eventBus
server 1
server 2
server 3
45
eventBus
server 1
webclientserver 2
server 3
46
eventBus
Publisher - subscriber
publish() //broadcast
like JMS Topics, no replying
47
eventBus
p2p
send() //point-to-point
like JMS Queues, can reply
48
eventBus
p2p
send() //point-to-point
like JMS Queues, can reply
round robin
49
eventBus
p2p
send() //point-to-point
like JMS Queues, can reply
round robin
50
public void start() {
getLogger().info("Broadcaster started");
vertx.setPeriodic(PERIOD_MS, timerID -> {
getLogger().info("Broadcasting message " + counter);
vertx.eventBus().publish(Consumer.CONSUMER_ADDRESS,
"Message " + counter);
counter++;
});
}
Broadcasting a message
51
public void start() {
getLogger().info("Broadcaster started");
vertx.setPeriodic(PERIOD_MS, timerID -> {
getLogger().info("Broadcasting message " + counter);
vertx.eventBus().send(Consumer.CONSUMER_ADDRESS,
"Message " + counter);
counter++;
});
}
Sending a message p2p
52
public void start() {
getLogger().info("Consumer started! " + hashCode());
vertx.eventBus().consumer(CONSUMER_ADDRESS, message -> {
getLogger().info("Received message: " + message.body());
});
}
Consuming a message
public void start() {
getLogger().info("Consumer started! " + hashCode());
vertx.eventBus().consumer(CONSUMER_ADDRESS, message -> {
getLogger().info("Received message: " + message.body());
message.reply("I got your message");
});
}
53
Consuming a message + replying
let’s code!
54
■periodic events
■sending/receiving events
●publish-subscribe / broadcast
○ one producer
○a few consumers
55
let’s code!
S2
■sending/receiving events
●point2p
○one consumer
○one consumer with response
○ a few consumers with response
56
let’s code!
S2
web client
57
58
HttpClientOptions opts = new HttpClientOptions()
.setDefaultHost("some.host.com");
HttpClient client = vertx.createHttpClient(opts);
client.get("/request/uri").handler(resp -> {
resp.bodyHandler(bodyBuffer -> {
System.out.println("here's the body");
System.out.println(bodyBuffer.toString());
});
}).end();
http client
■pulling data from http server
■parsing data with multiple verticles
59
let’s code!
S3
60
vert.x ecosystem
61
lightweight vert.x core
extensions
■web
■data access (mongoDB, redis, JDBC)
■security (basic auth, jdbc auth, jwt, shiro)
■reactive (based on RxJava)
■others
vert.x ecosystem
62
web server
63
web server
■vert.x core - very raw and basic HTTP server
■web server ext - neat path and content
routing
64
vertx.createHttpServer().requestHandler( req -> {
LOG.info(String.format("Got request [%s]", req.path()));
switch (req.path()) {
case "/" : req.response().end("Ok. Here's root"); break;
case "/other": req.response().end("Other things..."); break;
default:
req.response().setStatusCode(404).end("Unknown resource!");
}
}).listen(port)
vert.x core - very raw and basic HTTP server
■serving primitive
65
let’s code!
S4
66
Router router = new RouterImpl(vertx);
router.get("/users/:uid").handler( ctx -> {
String id = ctx.request().getParam("uid");
JsonObject user =
new JsonObject().put("id", id).put("name", "bartek");
ctx.response().end(user.encode());
});
HttpServer server = vertx.createHttpServer();
server.requestHandler(router::accept).listen(8080);
web server ext - neat path and content routing
67
router.post("/some/post/path")
router.put()
router.get("/user/data").consumes("application/json")
router.get("/user/data").consumes("text/html")
router.get("/info").produces("text/html")
router.get("/info").produces("text/plain")
web server ext - content routing
68
//SessionHandler must be preceded with SessionHandler
router.route().handler(CookieHandler.create());
router.route().handler(
SessionHandler.create(LocalSessionStore.create(vertx)));
router.get("/sessionCounter").handler(ctx -> {
ctx.session().get("counter");
}
web server ext - accessing session
69
vertx.sharedData().getLocalMap("myMap").get("myKeyInMap")
accessing shared data
■adding EventBus via websockets
■using shared data S4c
■using web session
■adding REST endpoints
●GET /sessionCounter
●GET /globalCounter
70
let’s code!
S4b/S4c
71
The Big App
let’s create Jenkins Monitor
■fetching build statuses parallely
■storing build statuses in shared map
■serving builds list GET /jobs
■serving build status GET /job/id
72
let’s code!
S5
73
benchmarking
74
benchmarking
https://www.techempower.com/benchmarks/#section=data-r8&hw=i7&test=plaintext
75
vert.x vs akka
verticles:
■are actor-like
■can be addressed
■can subscribe to many addresses
■can do processing jobs
■can send back content
■can have multiple instances of same class
76
vert.x vs akka
how vert.x scales
77
vertically
■verticle can have multiple instances
■each instance can have own processor core
horizontally
■clustering - lot’s of nodes
■eventbus reaches all nodes
78
how vert.x scales
polyglot
79
■java
■groovy
■javascript
■ruby
■...more to come!
80
polyglot
81
puts "Ruby for the win!"
eb = $vertx.event_bus()
# Send a message every second
$vertx.set_periodic(1000) { |v|
puts "RUBY: sending Ruby message"
eb.publish("producer.address", "Ruby shines!")
}
Ruby shines
82
var eb = vertx.eventBus();
eb.consumer("producer.address", function (message) {
console.log("JAVASCRIPT: Received a message: " + message.body());
});
console.log("Receiver ready!");
For JavaScript dare devils!
usecases
83
■effective use of servers’ resources
■parallel computing
■great as a backend for lots of (mobile)
clients
■nice integration platform
■could be awesome in microservices
84
usecases
YOU getting started
85
http://vertx.io/
https://github.com/vert-x3
https://github.com/zdanek/vertx-pres
86
YOU getting started
grab a sticker!
87
YOU getting started
have fun!
88
YOU getting started
I’m not the owner of the pictures used. Just found them on:
http://www.rantchic.com/wp-content/uploads/2013/12/Apollo-13.jpg
http://www.gamesaktuell.de/screenshots/1280x1024/2009/04/terminator_2_blu_ray03.jpg
http://tripoutlook.com/wp-content/uploads/2013/03/Car-parking.jpg
http://upload.wikimedia.org/wikipedia/commons/5/52/Parallel_Parking_cars.jpg
http://www.foreverbarcelona.com/wp-content/uploads/2014/02/Taxi-Tips.png
http://www.125p.eu/wp-content/uploads/2009/03/fiat-125p-zmiennicy-5.jpg
http://www.novosti.rs/upload/images/2011/07/2107/bg-taksi.jpg
http://i.livescience.com/images/i/000/024/292/iFF/neurons-120208.jpg?1328727600
89
All the pics used
90
Thank you

More Related Content

What's hot (20)

PDF
Introduction to Node.js: What, why and how?
Christian Joudrey
 
PDF
Philly Tech Week Introduction to NodeJS
Ross Kukulinski
 
PPTX
Node.js Patterns for Discerning Developers
cacois
 
KEY
Introduction to node.js
jacekbecela
 
PPTX
Bucks County Tech Meetup: node.js introduction
dshkolnikov
 
PPTX
Vert.x for Microservices Architecture
Idan Fridman
 
PDF
How to Test Asynchronous Code (v2)
Felix Geisendörfer
 
PDF
Comet with node.js and V8
amix3k
 
KEY
NodeJS
.toster
 
KEY
Writing robust Node.js applications
Tom Croucher
 
PPTX
Node.js Workshop - Sela SDP 2015
Nir Noy
 
PPTX
Java script at backend nodejs
Amit Thakkar
 
PDF
Meetup RomaJS - introduzione interattiva a Node.js - Luca Lanziani - Codemoti...
Codemotion
 
PDF
Non-blocking I/O, Event loops and node.js
Marcus Frödin
 
KEY
OSCON 2011 - Node.js Tutorial
Tom Croucher
 
PPTX
Intro to node and non blocking io
Amy Hua
 
PPTX
Intro to Node.js (v1)
Chris Cowan
 
PDF
NodeJS
LinkMe Srl
 
PDF
NodeJS for Beginner
Apaichon Punopas
 
PPTX
Node.js code tracing
Geng-Dian Huang
 
Introduction to Node.js: What, why and how?
Christian Joudrey
 
Philly Tech Week Introduction to NodeJS
Ross Kukulinski
 
Node.js Patterns for Discerning Developers
cacois
 
Introduction to node.js
jacekbecela
 
Bucks County Tech Meetup: node.js introduction
dshkolnikov
 
Vert.x for Microservices Architecture
Idan Fridman
 
How to Test Asynchronous Code (v2)
Felix Geisendörfer
 
Comet with node.js and V8
amix3k
 
NodeJS
.toster
 
Writing robust Node.js applications
Tom Croucher
 
Node.js Workshop - Sela SDP 2015
Nir Noy
 
Java script at backend nodejs
Amit Thakkar
 
Meetup RomaJS - introduzione interattiva a Node.js - Luca Lanziani - Codemoti...
Codemotion
 
Non-blocking I/O, Event loops and node.js
Marcus Frödin
 
OSCON 2011 - Node.js Tutorial
Tom Croucher
 
Intro to node and non blocking io
Amy Hua
 
Intro to Node.js (v1)
Chris Cowan
 
NodeJS
LinkMe Srl
 
NodeJS for Beginner
Apaichon Punopas
 
Node.js code tracing
Geng-Dian Huang
 

Similar to Vert.x v3 - high performance polyglot application toolkit (20)

PPTX
Vert.x devoxx london 2013
Stuart (Pid) Williams
 
PPT
JUDCon Brazil 2013 - Vert.x an introduction
Samuel Tauil
 
ODP
Groovy & Grails eXchange 2012 vert.x presentation
Stuart (Pid) Williams
 
PPTX
Vert.x Event Driven Non Blocking Reactive Toolkit
Brian S. Paskin
 
PDF
Introducing Vert.x 2.0 - Taking polyglot application development to the next ...
jaxLondonConference
 
PDF
Vert.x introduction
GR8Conf
 
PPTX
Building microservices with vert.x 3.0
Agraj Mangal
 
PPTX
Vertx
Vijay Shukla
 
PDF
Reactive Polyglot Microservices with OpenShift and Vert.x
Reactivesummit
 
PDF
Vert.x - 2014 JDay Lviv (English)
Bartek Zdanowski
 
PDF
Vertx
Alvaro Videla
 
PPTX
Vert.x - Reactive & Distributed [Devoxx version]
Orkhan Gasimov
 
ODP
Vert.x keynote for EclipseCon 2013
timfox111
 
PDF
Development with Vert.x: an event-driven application framework for the JVM
David Wu
 
PPTX
Reactive applications and microservices with Vert.x tool-kit
Victor Hugo
 
PDF
Vertx Basics
Souvik Maji
 
PDF
Vert.x - JDD 2013 (English)
Bartek Zdanowski
 
PDF
Vert.X: Microservices Were Never So Easy (Clement Escoffier)
Red Hat Developers
 
PDF
Vertx In Action Asynchronous And Reactive Java Julien Ponge
ratanaarizbe
 
Vert.x devoxx london 2013
Stuart (Pid) Williams
 
JUDCon Brazil 2013 - Vert.x an introduction
Samuel Tauil
 
Groovy & Grails eXchange 2012 vert.x presentation
Stuart (Pid) Williams
 
Vert.x Event Driven Non Blocking Reactive Toolkit
Brian S. Paskin
 
Introducing Vert.x 2.0 - Taking polyglot application development to the next ...
jaxLondonConference
 
Vert.x introduction
GR8Conf
 
Building microservices with vert.x 3.0
Agraj Mangal
 
Reactive Polyglot Microservices with OpenShift and Vert.x
Reactivesummit
 
Vert.x - 2014 JDay Lviv (English)
Bartek Zdanowski
 
Vert.x - Reactive & Distributed [Devoxx version]
Orkhan Gasimov
 
Vert.x keynote for EclipseCon 2013
timfox111
 
Development with Vert.x: an event-driven application framework for the JVM
David Wu
 
Reactive applications and microservices with Vert.x tool-kit
Victor Hugo
 
Vertx Basics
Souvik Maji
 
Vert.x - JDD 2013 (English)
Bartek Zdanowski
 
Vert.X: Microservices Were Never So Easy (Clement Escoffier)
Red Hat Developers
 
Vertx In Action Asynchronous And Reactive Java Julien Ponge
ratanaarizbe
 
Ad

More from Sages (20)

PDF
Python szybki start
Sages
 
PDF
Budowanie rozwiązań serverless w chmurze Azure
Sages
 
PDF
Docker praktyczne podstawy
Sages
 
PDF
Angular 4 pragmatycznie
Sages
 
PDF
Jak działa blockchain?
Sages
 
PDF
Qgis szybki start
Sages
 
PDF
Architektura SOA - wstęp
Sages
 
PDF
Bezpieczne dane w aplikacjach java
Sages
 
PDF
Wprowadzenie do technologi Big Data i Apache Hadoop
Sages
 
PDF
Architektura aplikacji android
Sages
 
PDF
Technologia Xamarin i wprowadzenie do Windows IoT core
Sages
 
PDF
Zrób dobrze swojej komórce - programowanie urządzeń mobilnych z wykorzystanie...
Sages
 
PDF
Szybkie wprowadzenie do eksploracji danych z pakietem Weka
Sages
 
PDF
Jak zacząć przetwarzanie małych i dużych danych tekstowych?
Sages
 
PDF
Wprowadzenie do Big Data i Apache Spark
Sages
 
PDF
Wprowadzenie do technologii Puppet
Sages
 
PDF
Budowa elementów GUI za pomocą biblioteki React - szybki start
Sages
 
PDF
Wprowadzenie do technologii Big Data / Intro to Big Data Ecosystem
Sages
 
PDF
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
Sages
 
PDF
Podstawy AngularJS
Sages
 
Python szybki start
Sages
 
Budowanie rozwiązań serverless w chmurze Azure
Sages
 
Docker praktyczne podstawy
Sages
 
Angular 4 pragmatycznie
Sages
 
Jak działa blockchain?
Sages
 
Qgis szybki start
Sages
 
Architektura SOA - wstęp
Sages
 
Bezpieczne dane w aplikacjach java
Sages
 
Wprowadzenie do technologi Big Data i Apache Hadoop
Sages
 
Architektura aplikacji android
Sages
 
Technologia Xamarin i wprowadzenie do Windows IoT core
Sages
 
Zrób dobrze swojej komórce - programowanie urządzeń mobilnych z wykorzystanie...
Sages
 
Szybkie wprowadzenie do eksploracji danych z pakietem Weka
Sages
 
Jak zacząć przetwarzanie małych i dużych danych tekstowych?
Sages
 
Wprowadzenie do Big Data i Apache Spark
Sages
 
Wprowadzenie do technologii Puppet
Sages
 
Budowa elementów GUI za pomocą biblioteki React - szybki start
Sages
 
Wprowadzenie do technologii Big Data / Intro to Big Data Ecosystem
Sages
 
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
Sages
 
Podstawy AngularJS
Sages
 
Ad

Recently uploaded (15)

PPTX
2025-07-13 Abraham 07 (shared slides).pptx
Dale Wells
 
PPTX
Inspired by VeinSense: Supercharge Your Hackathon with Agentic AI
ShubhamSharma2528
 
PDF
The Impact of Game Live Streaming on In-Game Purchases of Chinese Young Game ...
Shibaura Institute of Technology
 
PPTX
some leadership theories MBA management.pptx
rkseo19
 
PDF
Generalization predition MOOCs - Conference presentation - eMOOCs 2025
pmmorenom01
 
PPTX
BARRIERS TO EFFECTIVE COMMUNICATION.pptx
shraddham25
 
PDF
Cloud Computing Service Availability.pdf
chakrirocky1
 
PPTX
Pastor Bob Stewart Acts 21 07 09 2025.pptx
FamilyWorshipCenterD
 
PDF
Leveraging the Power of Jira Dashboard.pdf
siddharthshukla742740
 
PDF
The Family Secret (essence of loveliness)
Favour Biodun
 
PPTX
AI presentation for everyone in every fields
dodinhkhai1
 
PPTX
STURGEON BAY WI AG PPT JULY 6 2025.pptx
FamilyWorshipCenterD
 
PPTX
presentation on legal and regulatory action
raoharsh4122001
 
PPTX
Presentationexpressions You are student leader and have just come from a stud...
BENSTARBEATZ
 
PPTX
Food_and_Drink_Bahasa_Inggris_Kelas_5.pptx
debbystevani36
 
2025-07-13 Abraham 07 (shared slides).pptx
Dale Wells
 
Inspired by VeinSense: Supercharge Your Hackathon with Agentic AI
ShubhamSharma2528
 
The Impact of Game Live Streaming on In-Game Purchases of Chinese Young Game ...
Shibaura Institute of Technology
 
some leadership theories MBA management.pptx
rkseo19
 
Generalization predition MOOCs - Conference presentation - eMOOCs 2025
pmmorenom01
 
BARRIERS TO EFFECTIVE COMMUNICATION.pptx
shraddham25
 
Cloud Computing Service Availability.pdf
chakrirocky1
 
Pastor Bob Stewart Acts 21 07 09 2025.pptx
FamilyWorshipCenterD
 
Leveraging the Power of Jira Dashboard.pdf
siddharthshukla742740
 
The Family Secret (essence of loveliness)
Favour Biodun
 
AI presentation for everyone in every fields
dodinhkhai1
 
STURGEON BAY WI AG PPT JULY 6 2025.pptx
FamilyWorshipCenterD
 
presentation on legal and regulatory action
raoharsh4122001
 
Presentationexpressions You are student leader and have just come from a stud...
BENSTARBEATZ
 
Food_and_Drink_Bahasa_Inggris_Kelas_5.pptx
debbystevani36
 

Vert.x v3 - high performance polyglot application toolkit