vertx in production
DESCRIPTION
How to make your Vert.x setup ready for productionTRANSCRIPT
![Page 1: Vertx in production](https://reader036.vdocuments.mx/reader036/viewer/2022081514/5560fa60d8b42a91388b4dcc/html5/thumbnails/1.jpg)
PRODUCTION READY VERT.XBerlin | 12.04.2023
![Page 2: Vertx in production](https://reader036.vdocuments.mx/reader036/viewer/2022081514/5560fa60d8b42a91388b4dcc/html5/thumbnails/2.jpg)
2
TABLE OF CONTENTS
1.Introduction
2.The Beginning
3.What is Vert.x?
4.How to start?
5.Infrastructure as code
6.Vert.x module system
7.Integration with messaging system
8.Kafka module
Berlin | 2014 | zanox | JUG BB
![Page 3: Vertx in production](https://reader036.vdocuments.mx/reader036/viewer/2022081514/5560fa60d8b42a91388b4dcc/html5/thumbnails/3.jpg)
3Berlin | 2014 | zanox | JUG BB
INTRODUCTION ZANOX
Europe‘s leading performance advertising network
![Page 4: Vertx in production](https://reader036.vdocuments.mx/reader036/viewer/2022081514/5560fa60d8b42a91388b4dcc/html5/thumbnails/4.jpg)
4
THE BEGINNING
Berlin | 2014 | zanox | JUG BB
Java Magazin 04.14: Vert.x im UnternehmenseinsatzEntwicklung und Betrieb von asynchronen Applikationen mit Vert.x in der Praxis
![Page 5: Vertx in production](https://reader036.vdocuments.mx/reader036/viewer/2022081514/5560fa60d8b42a91388b4dcc/html5/thumbnails/5.jpg)
5Berlin | 2014 | zanox | JUG BB
THE BEGINNING
●New request processing-system for Zanox
●Requirements are pretty high (not negotiable):●Low latency●High throughput●Scalable●Resilient●Responsive●Event-Driven●Fast
![Page 6: Vertx in production](https://reader036.vdocuments.mx/reader036/viewer/2022081514/5560fa60d8b42a91388b4dcc/html5/thumbnails/6.jpg)
6Berlin | 2014 | zanox | JUG BB
THE BEGINNING
![Page 7: Vertx in production](https://reader036.vdocuments.mx/reader036/viewer/2022081514/5560fa60d8b42a91388b4dcc/html5/thumbnails/7.jpg)
7
“Vert.x is a lightweight, high performance application
platform for the JVM that's designed for modern
mobile, web, and enterprise applications.”
Vert.x
WHAT IS VERT.X?
Berlin | 2014 | zanox | JUG BB
![Page 8: Vertx in production](https://reader036.vdocuments.mx/reader036/viewer/2022081514/5560fa60d8b42a91388b4dcc/html5/thumbnails/8.jpg)
8Berlin | 2014 | zanox | JUG BB
WHAT IS VERT.X?
Polyglot
![Page 9: Vertx in production](https://reader036.vdocuments.mx/reader036/viewer/2022081514/5560fa60d8b42a91388b4dcc/html5/thumbnails/9.jpg)
9Berlin | 2014 | zanox | JUG BB
WHAT IS A VERTICLE?
●Classes with an own Classloader
●operates Single Threaded
●executed by an Event Loop
![Page 10: Vertx in production](https://reader036.vdocuments.mx/reader036/viewer/2022081514/5560fa60d8b42a91388b4dcc/html5/thumbnails/10.jpg)
10Berlin | 2014 | zanox | JUG BB
Event Loop Pool
Event Bus
V V V W W W
TAKE A LOOK INSIDE
![Page 11: Vertx in production](https://reader036.vdocuments.mx/reader036/viewer/2022081514/5560fa60d8b42a91388b4dcc/html5/thumbnails/11.jpg)
11Berlin | 2014 | zanox | JUG BB
WHAT‘S DEEP INSIDE?
●Build on top of Netty 4
●Uses Hazelcast for node discovery
●Jackson for JSON
●Java7+
![Page 12: Vertx in production](https://reader036.vdocuments.mx/reader036/viewer/2022081514/5560fa60d8b42a91388b4dcc/html5/thumbnails/12.jpg)
12Berlin | 2014 | zanox | JUG BB
HOW TO START?
●Prerequisite: JDK 7
●download and unzip file from vertx.io
●put /bin directory to PATH variable
![Page 13: Vertx in production](https://reader036.vdocuments.mx/reader036/viewer/2022081514/5560fa60d8b42a91388b4dcc/html5/thumbnails/13.jpg)
13Berlin | 2014 | zanox | JUG BB
HOW TO START?
●mvn archetype:generate -Dfilter=io.vertx: (do not forget the colon!)
●generates structure for all languages (JS, Ruby, Groovy, Python)
●maven pom is already set with relevant data
![Page 14: Vertx in production](https://reader036.vdocuments.mx/reader036/viewer/2022081514/5560fa60d8b42a91388b4dcc/html5/thumbnails/14.jpg)
14Berlin | 2014 | zanox | JUG BB
HOW TO START?
![Page 15: Vertx in production](https://reader036.vdocuments.mx/reader036/viewer/2022081514/5560fa60d8b42a91388b4dcc/html5/thumbnails/15.jpg)
15Berlin | 2014 | zanox | JUG BB
BEST PRACTICES
![Page 16: Vertx in production](https://reader036.vdocuments.mx/reader036/viewer/2022081514/5560fa60d8b42a91388b4dcc/html5/thumbnails/16.jpg)
16Berlin | 2014 | zanox | JUG BB
BEST PRACTICES
●do not block the loop
●put blocking code or extensive computation into worker verticles
●keep the application responsive
●stress test as often as possible
●encapsulate common code in modules (more on this later)
![Page 17: Vertx in production](https://reader036.vdocuments.mx/reader036/viewer/2022081514/5560fa60d8b42a91388b4dcc/html5/thumbnails/17.jpg)
17Berlin | 2014 | zanox | JUG BB
INFRASTRUCTURE AS CODE
![Page 18: Vertx in production](https://reader036.vdocuments.mx/reader036/viewer/2022081514/5560fa60d8b42a91388b4dcc/html5/thumbnails/18.jpg)
18
INFRASTRUCTURE AS CODE
Berlin | 2014 | zanox | JUG BB
"CHEF IS LIKE A LITTLE SYSTEM ADMIN ROBOT ... YOU TELL IT HOW YOU WANT YOUR SYSTEM CONFIGURED, AND IT WILL DO ALL THE DIRTY WORK.”
![Page 19: Vertx in production](https://reader036.vdocuments.mx/reader036/viewer/2022081514/5560fa60d8b42a91388b4dcc/html5/thumbnails/19.jpg)
19Berlin | 2014 | zanox | JUG BB
INFRASTRUCTURE AS CODE
![Page 20: Vertx in production](https://reader036.vdocuments.mx/reader036/viewer/2022081514/5560fa60d8b42a91388b4dcc/html5/thumbnails/20.jpg)
20Berlin | 2014 | zanox | JUG BB
INFRASTRUCTURE AS CODE
Chef Cookbook
![Page 21: Vertx in production](https://reader036.vdocuments.mx/reader036/viewer/2022081514/5560fa60d8b42a91388b4dcc/html5/thumbnails/21.jpg)
21Berlin | 2014 | zanox | JUG BB
INFRASTRUCTURE AS CODE
![Page 22: Vertx in production](https://reader036.vdocuments.mx/reader036/viewer/2022081514/5560fa60d8b42a91388b4dcc/html5/thumbnails/22.jpg)
22Berlin | 2014 | zanox | JUG BB
VERT.X MODULE SYSTEM
●Vert.x has a powerful module system.
●Package your Vert.x components into modules for encapsulation and reuse.
●The module is a zip file
●It can be just plugged in into your application
![Page 23: Vertx in production](https://reader036.vdocuments.mx/reader036/viewer/2022081514/5560fa60d8b42a91388b4dcc/html5/thumbnails/23.jpg)
23Berlin | 2014 | zanox | JUG BB
VERT.X MODULE SYSTEM
●Share your modules with the community by putting them in Maven Central, any other Maven repository, or in Bintray.
●Advertise your module in the module registry.
![Page 24: Vertx in production](https://reader036.vdocuments.mx/reader036/viewer/2022081514/5560fa60d8b42a91388b4dcc/html5/thumbnails/24.jpg)
24Berlin | 2014 | zanox | JUG BB
VERT.X MODULE REGISTRY
●Just fill in the form and wait for approval:
![Page 25: Vertx in production](https://reader036.vdocuments.mx/reader036/viewer/2022081514/5560fa60d8b42a91388b4dcc/html5/thumbnails/25.jpg)
25Berlin | 2014 | zanox | JUG BB
INTEGRATION WITH MESSAGING SYSTEM
●Apache Kafka is a publish-subscribe messaging implemented as a distributed commit log.
●Fast
●Scalable
●Durable
●Distributed
KAFKA MESSAGING SYSTEM
![Page 26: Vertx in production](https://reader036.vdocuments.mx/reader036/viewer/2022081514/5560fa60d8b42a91388b4dcc/html5/thumbnails/26.jpg)
26Berlin | 2014 | zanox | JUG BB
INTEGRATION WITH MESSAGING SYSTEM
●Topic - categories for feeds of messages
●Producer - publishes messages to topics
●Consumer - subscribes to topics and process the feed of published messages consumers
●Broker - Kafka is run as a cluster comprised of one or more servers each of which is called a broker.
MAIN TERMINOLOGY:
![Page 27: Vertx in production](https://reader036.vdocuments.mx/reader036/viewer/2022081514/5560fa60d8b42a91388b4dcc/html5/thumbnails/27.jpg)
27Berlin | 2014 | zanox | JUG BB
KAFKA MODULE
●Application sends messages to Kafka module using Vert.x event bus
●Kafka module acts as a producer
●Available on Maven Central and Vert.x module registry
![Page 28: Vertx in production](https://reader036.vdocuments.mx/reader036/viewer/2022081514/5560fa60d8b42a91388b4dcc/html5/thumbnails/28.jpg)
28Berlin | 2014 | zanox | JUG BB
KAFKA MODULE IN MODULE REGISTRY
Open sourced Kafka module in Vert.x’s module registry - http://modulereg.vertx.io/
![Page 29: Vertx in production](https://reader036.vdocuments.mx/reader036/viewer/2022081514/5560fa60d8b42a91388b4dcc/html5/thumbnails/29.jpg)
29Berlin | 2014 | zanox | JUG BB
USING VERT.X MODULE
First, deploy the module into your application:
container.deployModule("com.zanox.vertx~mod-kafka~1.0.2", config);
![Page 30: Vertx in production](https://reader036.vdocuments.mx/reader036/viewer/2022081514/5560fa60d8b42a91388b4dcc/html5/thumbnails/30.jpg)
30Berlin | 2014 | zanox | JUG BB
USING KAFKA MODULE
JsonObject config = new JsonObject();
config.putString("kafka-topic", ‘kafka_topic“);
config.putString("metadata.broker.list", “localhost:9092”);
config.putString("request.required.acks", "1");
CONFIGURATION IS A JSON OBJECT:
![Page 31: Vertx in production](https://reader036.vdocuments.mx/reader036/viewer/2022081514/5560fa60d8b42a91388b4dcc/html5/thumbnails/31.jpg)
31Berlin | 2014 | zanox | JUG BB
METRICS OF VERT.X PROJECT
●On 4 Cores virtual machine we had the following results:
●~28 K requests per second without Kafka, with lookup from Redis
●~18 K requests per second with Kafka and lookup from Redis
![Page 32: Vertx in production](https://reader036.vdocuments.mx/reader036/viewer/2022081514/5560fa60d8b42a91388b4dcc/html5/thumbnails/32.jpg)
32Berlin | 2014 | zanox | JUG BB
Q & A