Verticle instances and event loops

1,726 views
Skip to first unread message

Anil

unread,
Feb 4, 2016, 1:26:37 AM2/4/16
to vert.x
HI,

I am little confused with instances vs event loops.

Documentation says ""Vert.x works differently here. Instead of a single event loop, each Vertx instance maintains several event loops. By default we choose the number based on the number of available cores on the machine, but this can be overridden."

if I am not wrong, max number of event loops will be number of cores of the machine. Agree ?

number of event loops defined in vertx options will be per instance ?

How vertx works with 8 instances with 8 event loops per instance configuration on a 32 core machine ? please clarify. Thanks.

Regards,
Anil



Thomas SEGISMONT

unread,
Feb 4, 2016, 12:07:53 PM2/4/16
to ve...@googlegroups.com
Hi,

The default event loop pool size is twice the number of cores on the machine. This pool size applies to every Vertx instance.

If you create 8 Vertx instances and configure the options to get 8 event loops in the pool size, you will get 36 event loops, regardless of the number of cores.

But it's not clear to me why you would like to create many Vertx instances in the same VM.

Regards,
Thomas


--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/bbbbeb69-fc0f-47d1-bb99-61398ec600fb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jez P

unread,
Feb 4, 2016, 12:52:26 PM2/4/16
to vert.x
Don't confuse vertx instances with verticle instances. Typically you'd only want one vertx instance per JVM. You might want lots of instances of a given verticle deployed, but that's not the same as multiple vertx instances.

Anil

unread,
Feb 9, 2016, 12:00:13 AM2/9/16
to vert.x
Hi Thomas and Jez,

Thanks for you responses.

Will there be effects if we deploy number of vertx applications on same jvm ? With this , on 8 core machine, 32 event loops. how it will impact number of requests ? 

Regards,
Anil

lukjel

unread,
Feb 9, 2016, 4:45:12 AM2/9/16
to vert.x
I'm little confused... I expected 64 loops (8 x 8 = 64). Right?

reg.
-l.

lukjel

unread,
Feb 9, 2016, 5:23:18 AM2/9/16
to vert.x
Hi.

Here is my understanding - how event loops and vertices are working.

Let's say: you've got one Vertx instance with 2 event loops and you're deploying 5 vertices (one instance each) then we end with:
event loop 1 - verticles A,C,E
event loop 2 - verticles B, D
Each of verticles consumes one message.
So - in case we have only messages "a" and "c" and "e" then only ONE event loop will be busy and second thread will be not used... So it is important to think - how and what is deployed.
One possible solution is to create ONE verticle with all handlers for every message. And then deploy it as many times as many cores you've got.

Remember - do not block event loop!

Running more than one instance of vertex per machine is imho not so good idea. There is no benefits.

Also - running more event loops than cores is also not good - then we have massive "context switch" and it costs...

My solution: build only few verticles with many handlers each. (verticle A - "a", "b", "c", verticle B - "d", "e"). On machine with 8 cores I start 7 event loops. I deploy verticle A and B with many instances (6 x A and 3 x B - this is important issue and depends on the project and number of instances and should be eq. or grt. then # event loops). One core is free for workers (if present) and system work.

Example: I've got message "a" which is the most frequent and important one, and 7 others ("b","c","d","e",...) which are also VERY important but not so frequent. Then I prepare verticle A and B. A consumes only message "a", and B consumes others. On 8 core machine I start vertex with 7 event loops.
Verticle A deploy 5 times and B - 2 times.

However I never ever make a test is this better then A - 7 times and B - 7 times...

The most important thing - do not block event loop! and deploy at least as many messages as many event loops you've got.

Does it helps?

Reg.
Lukasz

Anil

unread,
Feb 9, 2016, 11:13:21 PM2/9/16
to vert.x
Thank you Lukasz.

You are right, i did not add that 32 event loops is for 2 vertx instances.
Reply all
Reply to author
Forward
0 new messages