+ All Categories
Home > Technology > Vert.x - JDD 2013 (English)

Vert.x - JDD 2013 (English)

Date post: 08-May-2015
Category:
Upload: bartek-zdanowski
View: 5,395 times
Download: 1 times
Share this document with a friend
Description:
Introduction to vert.x platform/framework (http://vertx.io) Shown on JDD 2013 Cracow, Poland
28
vert.x Bartek Zdanowski TouK
Transcript
Page 1: Vert.x - JDD 2013 (English)

vert.xBartek Zdanowski

TouK

Page 2: Vert.x - JDD 2013 (English)

vert.x

Bartek Zdanowski● developer @ TouK● co-organizer of Confitura conference● Warszawa JUG member● father and husband :)

@BartekZdanowski

Page 3: Vert.x - JDD 2013 (English)

what actually vert.x is?

vert.x

Page 4: Vert.x - JDD 2013 (English)

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 5: Vert.x - JDD 2013 (English)

vert.x

● what is the Problem?○ Tomcat: 200 threads = 200 connections○ rest of incoming connections must wait…

Page 6: Vert.x - JDD 2013 (English)

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 7: Vert.x - JDD 2013 (English)

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 8: Vert.x - JDD 2013 (English)

vert.x

● different approach!● program must wait for data. But only one thread should

wait!

event

thread

Page 9: Vert.x - JDD 2013 (English)

vert.x

● different approach!● program always should wait for data! but only one

thread should wait!

event

reactor

thread

Page 10: Vert.x - JDD 2013 (English)

vert.x

● how it’s done in vert.x?○ multi-reactor pattern○ thread pool equals to cores count

Page 11: Vert.x - JDD 2013 (English)

vert.x

● how it’s done in vert.x?○ introduces asynchronous programming approach○ event driven○ distributed○ scalable○ thread safe○ uses actor model

Page 12: Vert.x - JDD 2013 (English)

vert.x

● demo

Page 13: Vert.x - JDD 2013 (English)

vert.x

● thread safe? when?

class MyService {public synchronized Result doSomething(Data data) {

//do some critical stuff}

}

Page 14: Vert.x - JDD 2013 (English)

vert.x

● thread safe? when?

class MyService {public synchronized Result doSomething(Data data) {

//do some critical stuff}

}

● only when 1 thread!

Page 15: Vert.x - JDD 2013 (English)

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

Page 16: Vert.x - JDD 2013 (English)

vert.x

Publisher

EventBus

Subscriber1 Subscriber2

Publisher - subcriberpublish() //broadcast

Page 17: Vert.x - JDD 2013 (English)

vert.x

Publisher

EventBus

Subscriber1 Subscriber2

Publisher - subcribersend() //point-to-point

Page 18: Vert.x - JDD 2013 (English)

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 19: Vert.x - JDD 2013 (English)

vert.x

● EventBus○ distributed - cluster○ can be spanned to web client side via SockJS

Page 20: Vert.x - JDD 2013 (English)

vert.x

Publisher

EventBus

Subscriber1 Subscriber2cluster!

host1 host2 host3

Page 21: Vert.x - JDD 2013 (English)

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 22: Vert.x - JDD 2013 (English)

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

Page 23: Vert.x - JDD 2013 (English)

vert.x

● Opponents?● node.js! really?!

http://www.cubrid.org/blog/dev-platform/inside-vertx-comparison-with-nodejs/

Page 24: Vert.x - JDD 2013 (English)

vert.x

● Opponents?● node.js! really?!

http://www.cubrid.org/blog/dev-platform/inside-vertx-comparison-with-nodejs/

Page 25: Vert.x - JDD 2013 (English)

vert.x

● To summarize○ extremely scalable○ thread safe and multithreaded○ distributed eventbus○ polyglot○ ready for year 2020 - 30 bln of devices ;)

Page 26: Vert.x - JDD 2013 (English)

vert.x

vert.x on Raspberry Pi! Monitoring Jenkins builds!

http://touk.pl/blog/en/2013/09/30/our-build-lights-in-action/

Page 27: Vert.x - JDD 2013 (English)

demo

vert.x

Page 28: Vert.x - JDD 2013 (English)

Thank you!

vert.x


Recommended