Vert.x is an asynchronous and event-driven framework that allows for highly scalable applications. It uses a multi-reactor pattern with a thread pool sized to the number of cores to avoid blocking and enable asynchronous programming. Applications are built as independent vertices that communicate asynchronously through a distributed event bus. This approach allows Vert.x applications to easily scale across multiple servers in a cluster to handle large numbers of concurrent connections from millions of devices.
4. vert.x
● what is the Problem?
○ number of mobile users raises from year to year*
■ 2,1 bln in 2012
■ 7 bln in 2018
○ number of intelligent devices raises
■ Internet of things - 30 bln in 2020!**
■ IPv6 is already ready for all of them
* http://mobithinking.com/mobile-marketing-tools/latest-mobile-stats/b
** http://en.wikipedia.org/wiki/Internet_of_Things
5. vert.x
● what is the Problem?
○ Tomcat: 200 threads = 200 connections
○ rest of incoming connections must wait…
6. vert.x
● what is the Problem?
● 1 thread handles one task
○ if thread is waiting for job to finish, whole queue of
tasks waits
○ traditional synchronous approach
○ waiting for job to finish (loop!)
7. vert.x
● different approach!
○
○
○
○
1 task = series of events lousely coupled
asynchronous
event that informs that new job/data is waiting
program should release thread instead of waiting for
operation (I/O) to be finished
13. vert.x
● thread safe? when?
class MyService {
public synchronized Result doSomething(Data data) {
//do some critical stuff
○
}
}
14. vert.x
● thread safe? when?
class MyService {
public synchronized Result doSomething(Data data) {
//do some critical stuff
}
}
● only when 1 thread!
15. vert.x
● thread safe? when?
○ each verticle instance is always executed by the
same thread from thrad pool
○ separated classloaders for each verticle instance
○ event bus separates threads
○ shared data: maps, sets
18. vert.x
● EventBus
○ publish() - all subscribers
○ send() - only one subscriber, round robin
○ queueing of messages to be delivered
● but
○ no acknowledgement
○ messages are stored in memory only - volatile
messages!
21. vert.x
● how vert.x scales
○
○
○
○
many instances of one verticle
clustering (auto-magic!)
eventbus spans through all nodes of cluster
uses all available cores
22. vert.x
● other features
○ Polyglot
■ Java, JavaScript, CoffeeScript, Ruby, Python,
Groovy + Scala, Clojure and...PHP
○ modules + public repo
○ embedding vert.x in application
○ Nice Http server + Sockets
○ Filesystem API