vert.x - 2014 jday lviv (english)
TRANSCRIPT
![Page 1: Vert.x - 2014 JDay Lviv (English)](https://reader033.vdocuments.site/reader033/viewer/2022052322/557c4bbbd8b42a936c8b4900/html5/thumbnails/1.jpg)
Bartek Zdanowski
![Page 2: Vert.x - 2014 JDay Lviv (English)](https://reader033.vdocuments.site/reader033/viewer/2022052322/557c4bbbd8b42a936c8b4900/html5/thumbnails/2.jpg)
vert.x
Bartek Zdanowski● developer @ TouK● co-organizer of Confitura conference● vertx lover● father and husband :)
@BartekZdanowski
![Page 3: Vert.x - 2014 JDay Lviv (English)](https://reader033.vdocuments.site/reader033/viewer/2022052322/557c4bbbd8b42a936c8b4900/html5/thumbnails/3.jpg)
what actually vert.x is?
vert.x
![Page 4: Vert.x - 2014 JDay Lviv (English)](https://reader033.vdocuments.site/reader033/viewer/2022052322/557c4bbbd8b42a936c8b4900/html5/thumbnails/4.jpg)
vert.x
● application platform● concurrent code● thread safe● event driven● polyglot● with very nice event bus● scalable
![Page 5: Vert.x - 2014 JDay Lviv (English)](https://reader033.vdocuments.site/reader033/viewer/2022052322/557c4bbbd8b42a936c8b4900/html5/thumbnails/5.jpg)
vert.x
![Page 6: Vert.x - 2014 JDay Lviv (English)](https://reader033.vdocuments.site/reader033/viewer/2022052322/557c4bbbd8b42a936c8b4900/html5/thumbnails/6.jpg)
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
![Page 7: Vert.x - 2014 JDay Lviv (English)](https://reader033.vdocuments.site/reader033/viewer/2022052322/557c4bbbd8b42a936c8b4900/html5/thumbnails/7.jpg)
vert.x
● what is the Problem?○ Tomcat: 200 threads = 200 connections○ rest of incoming connections must wait…
![Page 8: Vert.x - 2014 JDay Lviv (English)](https://reader033.vdocuments.site/reader033/viewer/2022052322/557c4bbbd8b42a936c8b4900/html5/thumbnails/8.jpg)
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!)
![Page 9: Vert.x - 2014 JDay Lviv (English)](https://reader033.vdocuments.site/reader033/viewer/2022052322/557c4bbbd8b42a936c8b4900/html5/thumbnails/9.jpg)
vert.x
* Thread Pools
http://tripoutlook.com/wp-content/uploads/2013/03/Car-parking.jpg
![Page 10: Vert.x - 2014 JDay Lviv (English)](https://reader033.vdocuments.site/reader033/viewer/2022052322/557c4bbbd8b42a936c8b4900/html5/thumbnails/10.jpg)
vert.x
* Thread Pools
http://upload.wikimedia.org/wikipedia/commons/5/52/Parallel_Parking_cars.jpg
![Page 11: Vert.x - 2014 JDay Lviv (English)](https://reader033.vdocuments.site/reader033/viewer/2022052322/557c4bbbd8b42a936c8b4900/html5/thumbnails/11.jpg)
vert.x
* Thread Pools
http://avtovesti.com/wp-content/uploads/2012/05/taxi1.jpg
![Page 12: Vert.x - 2014 JDay Lviv (English)](https://reader033.vdocuments.site/reader033/viewer/2022052322/557c4bbbd8b42a936c8b4900/html5/thumbnails/12.jpg)
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
![Page 13: Vert.x - 2014 JDay Lviv (English)](https://reader033.vdocuments.site/reader033/viewer/2022052322/557c4bbbd8b42a936c8b4900/html5/thumbnails/13.jpg)
vert.x
● different approach!● program must wait for data. But only one thread should
wait!
event
thread
![Page 14: Vert.x - 2014 JDay Lviv (English)](https://reader033.vdocuments.site/reader033/viewer/2022052322/557c4bbbd8b42a936c8b4900/html5/thumbnails/14.jpg)
vert.x
● different approach!● program must wait for data. But only one thread should
wait!
event
reactor
thread
![Page 15: Vert.x - 2014 JDay Lviv (English)](https://reader033.vdocuments.site/reader033/viewer/2022052322/557c4bbbd8b42a936c8b4900/html5/thumbnails/15.jpg)
vert.x
● how it’s done in vert.x?○ multi-reactor pattern○ thread pool equals to cores count
![Page 16: Vert.x - 2014 JDay Lviv (English)](https://reader033.vdocuments.site/reader033/viewer/2022052322/557c4bbbd8b42a936c8b4900/html5/thumbnails/16.jpg)
vert.x
● how it’s done in vert.x?○ introduces asynchronous programming approach○ event driven○ distributed○ scalable○ thread safe○ uses actor model
![Page 17: Vert.x - 2014 JDay Lviv (English)](https://reader033.vdocuments.site/reader033/viewer/2022052322/557c4bbbd8b42a936c8b4900/html5/thumbnails/17.jpg)
vert.x
Show me the code!(demo)
![Page 18: Vert.x - 2014 JDay Lviv (English)](https://reader033.vdocuments.site/reader033/viewer/2022052322/557c4bbbd8b42a936c8b4900/html5/thumbnails/18.jpg)
vert.x
● thread safe? when?
○
class MyService {public synchronized Result doSomething(Data data) {
//do some critical stuff}
}
![Page 19: Vert.x - 2014 JDay Lviv (English)](https://reader033.vdocuments.site/reader033/viewer/2022052322/557c4bbbd8b42a936c8b4900/html5/thumbnails/19.jpg)
vert.x
● thread safe? when?
class MyService {public synchronized Result doSomething(Data data) {
//do some critical stuff}
}
● only when 1 thread!
![Page 20: Vert.x - 2014 JDay Lviv (English)](https://reader033.vdocuments.site/reader033/viewer/2022052322/557c4bbbd8b42a936c8b4900/html5/thumbnails/20.jpg)
vert.x
● thread safe? when?○ each verticle instance is always executed by the
same thread from thread pool○ separated classloaders for each verticle instance○ event bus separates threads○ shared data: maps, sets
![Page 21: Vert.x - 2014 JDay Lviv (English)](https://reader033.vdocuments.site/reader033/viewer/2022052322/557c4bbbd8b42a936c8b4900/html5/thumbnails/21.jpg)
vert.x
Publisher
EventBus
Subscriber1 Subscriber2
Publisher - subcriberpublish() //broadcast
![Page 22: Vert.x - 2014 JDay Lviv (English)](https://reader033.vdocuments.site/reader033/viewer/2022052322/557c4bbbd8b42a936c8b4900/html5/thumbnails/22.jpg)
vert.x
Publisher
EventBus
Subscriber1 Subscriber2
Publisher - subcribersend() //point-to-point
![Page 23: Vert.x - 2014 JDay Lviv (English)](https://reader033.vdocuments.site/reader033/viewer/2022052322/557c4bbbd8b42a936c8b4900/html5/thumbnails/23.jpg)
vert.x
Publisher
EventBus
Subscriber1 Subscriber2
Publisher - subcribersend() //point-to-pointround robin
![Page 24: Vert.x - 2014 JDay Lviv (English)](https://reader033.vdocuments.site/reader033/viewer/2022052322/557c4bbbd8b42a936c8b4900/html5/thumbnails/24.jpg)
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!
![Page 25: Vert.x - 2014 JDay Lviv (English)](https://reader033.vdocuments.site/reader033/viewer/2022052322/557c4bbbd8b42a936c8b4900/html5/thumbnails/25.jpg)
vert.x
● EventBus○ distributed - cluster○ can be spanned to web client side via SockJS
![Page 26: Vert.x - 2014 JDay Lviv (English)](https://reader033.vdocuments.site/reader033/viewer/2022052322/557c4bbbd8b42a936c8b4900/html5/thumbnails/26.jpg)
vert.x
Publisher
EventBus
Subscriber1 Subscriber2cluster!
host1 host2 host3
![Page 27: Vert.x - 2014 JDay Lviv (English)](https://reader033.vdocuments.site/reader033/viewer/2022052322/557c4bbbd8b42a936c8b4900/html5/thumbnails/27.jpg)
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
![Page 28: Vert.x - 2014 JDay Lviv (English)](https://reader033.vdocuments.site/reader033/viewer/2022052322/557c4bbbd8b42a936c8b4900/html5/thumbnails/28.jpg)
vert.x - modules
● deployment units● contain code and all dependencies● reusable code● can be shared via Bintray, Maven ● can be published on Vert.x module registry
![Page 29: Vert.x - 2014 JDay Lviv (English)](https://reader033.vdocuments.site/reader033/viewer/2022052322/557c4bbbd8b42a936c8b4900/html5/thumbnails/29.jpg)
vert.x - modules
Modules demo
![Page 30: Vert.x - 2014 JDay Lviv (English)](https://reader033.vdocuments.site/reader033/viewer/2022052322/557c4bbbd8b42a936c8b4900/html5/thumbnails/30.jpg)
vert.x - webserver
● simple and fast● with event bus exposed by SockJS
![Page 31: Vert.x - 2014 JDay Lviv (English)](https://reader033.vdocuments.site/reader033/viewer/2022052322/557c4bbbd8b42a936c8b4900/html5/thumbnails/31.jpg)
vert.x – getting started
● http://vertx.io● User maven archetype:
Create first verticle withmvn archetype:generate -Dfilter=io.vertx:
● Add some codemvn install
● Ready to go!mvn vertx:runMod
![Page 32: Vert.x - 2014 JDay Lviv (English)](https://reader033.vdocuments.site/reader033/viewer/2022052322/557c4bbbd8b42a936c8b4900/html5/thumbnails/32.jpg)
vert.x
● other features○ Polyglot
■ Java, JavaScript, CoffeeScript, Ruby, Python, Groovy + Scala, Clojure and...PHP
○ embedding vert.x in application○ Filesystem API○ DNS API
![Page 33: Vert.x - 2014 JDay Lviv (English)](https://reader033.vdocuments.site/reader033/viewer/2022052322/557c4bbbd8b42a936c8b4900/html5/thumbnails/33.jpg)
vert.x
● Opponents?● node.js! really?!
http://www.cubrid.org/blog/dev-platform/inside-vertx-comparison-with-nodejs/
![Page 34: Vert.x - 2014 JDay Lviv (English)](https://reader033.vdocuments.site/reader033/viewer/2022052322/557c4bbbd8b42a936c8b4900/html5/thumbnails/34.jpg)
vert.x
● Opponents?● node.js! really?!
http://www.cubrid.org/blog/dev-platform/inside-vertx-comparison-with-nodejs/
![Page 35: Vert.x - 2014 JDay Lviv (English)](https://reader033.vdocuments.site/reader033/viewer/2022052322/557c4bbbd8b42a936c8b4900/html5/thumbnails/35.jpg)
vert.x
● To summarize○ extremely scalable○ thread safe and multithreaded○ extremely efficient○ distributed eventbus○ polyglot○ modularized○ ready for year 2020 - 30 bln of devices ;)
![Page 36: Vert.x - 2014 JDay Lviv (English)](https://reader033.vdocuments.site/reader033/viewer/2022052322/557c4bbbd8b42a936c8b4900/html5/thumbnails/36.jpg)
vert.x
vert.x on Raspberry Pi! Monitoring Jenkins builds!
http://touk.pl/blog/en/2013/09/30/our-build-lights-in-action/
![Page 37: Vert.x - 2014 JDay Lviv (English)](https://reader033.vdocuments.site/reader033/viewer/2022052322/557c4bbbd8b42a936c8b4900/html5/thumbnails/37.jpg)
https://github.com/zdanek/vertx-pres
https://github.com/zdanek/vertx-module-example
https://docs.google.com/presentation/d/1SvEyExQJbjTKI7RAMPZhTFYJBz6h
MhI7w2pie_LNtDw/edit?usp=sharing
vert.x
![Page 38: Vert.x - 2014 JDay Lviv (English)](https://reader033.vdocuments.site/reader033/viewer/2022052322/557c4bbbd8b42a936c8b4900/html5/thumbnails/38.jpg)
Дякую
vert.x