Java Vertx embedded: Thread pool configuration

945 views
Skip to first unread message

David Pinedo

unread,
May 29, 2013, 5:28:04 AM5/29/13
to ve...@googlegroups.com
Hello,

I have an application that needs to communicate with other application in other machine via HTTP (this second machine doesn't use Vertx).
So, in my first application I have a Vertx instance, and a HTTPclient and a HTTPserver instantiated by this Vertx instance.
I have several dobuts in how Vertx works:
1) I can see that Vertx has created a pool of threads. It's possible to set the number of threads created by Vertx and to change the name of this threads (se llaman New I/O worker #i)?
2) As I have an HTTPClient and an HTTPServer, in vertx nomenclature: I have two verticles, isn't it?
3)So, if I have 2 verticles, and in the manual it's said that a verticle is allways executed by the same "event loop", I need a pool with only two threads, isn't it?


Thomas Hirsch

unread,
May 30, 2013, 5:51:25 PM5/30/13
to ve...@googlegroups.com
I feel like there are some misunderstandings here... Maybe take a closer look at the documentation? It's very nice actually and deserves to be read thoroughly ;)

Tim Fox

unread,
May 31, 2013, 2:34:17 AM5/31/13
to ve...@googlegroups.com
On 30/05/13 22:51, Thomas Hirsch wrote:
> Am Mittwoch, 29. Mai 2013 11:28:04 UTC+2 schrieb David Pinedo:
>
>> Hello,
>>
>> I have an application that needs to communicate with other application in
>> other machine via HTTP (this second machine doesn't use Vertx).
>> So, in my first application I have a Vertx instance, and a HTTPclient and
>> a HTTPserver instantiated by this Vertx instance.
>> I have several dobuts in how Vertx works:
>> 1) I can see that Vertx has created a pool of threads. It's possible to
>> set the number of threads created by Vertx and to change the name of this
>> threads (se llaman New I/O worker #i)?
There should be no good reason to change the number of event loop
threads - this is tuned to the number of cores on your machine.
>> 2) As I have an HTTPClient and an HTTPServer, in vertx nomenclature: I
>> have two verticles, isn't it?

A verticle is the smallest execution unit of Vert.x, a single verticle
can contain as many Http clients and servers as you like

>> 3)So, if I have 2 verticles, and in the manual it's said that a verticle
>> is allways executed by the same "event loop", I need a pool with only two
>> threads, isn't it?

The number of event loop threads is not related to the number of
verticles, it's related to the number of cores on your machine.
>>
>> I feel like there are some misunderstandings here... Maybe take a closer
>> look at the documentation?
I certainly recommend starting with the main manual, it goes over most
of these concepts :)

Romain Gilles

unread,
Jun 3, 2013, 4:39:05 AM6/3/13
to ve...@googlegroups.com
Hi,
I think in some cases you may want to reduce the number of thread used by vert.x thread pool.

Romain

David Pinedo

unread,
Jun 3, 2013, 11:28:04 AM6/3/13
to ve...@googlegroups.com
Thank you  Tim,

I had read the main manual for several times, and is quite good explained, but when you are working in a embedded mode, some concepts are not so clear.

I have a host with 8 cores so, when I instantiate a Vertx: 8 threads are created. 
After instancing Vertx, I create a Httpserver and a Httpclient. What I can see, it's that Httpclient methods are always runned only by one thread (and always the same) and the Httpserver is always runned by other thread (always the same).
vertx = Vertx.newVertx();
mojitoServer=new HttpVertxServer(vertx,bindingHost, bindingPort, loggerName);
mojitoClient=new HttpVertxClient(vertx,prophecyAddr, prophecyPort, loggerName);

My application is also doing other stuffs (that are not related with Vertx) so, I need other threads to manage these tasks.
Vertx is creating threads that are never used (at least in my scenario) So, I'd like not to create innecesary threads setting the thread pool size.
Moreover, I want to monitorize my application and I'd like to change the name asigned to these threads.
There is a way to configure this in Vertx?

Ian Rose

unread,
Oct 17, 2013, 11:01:42 AM10/17/13
to ve...@googlegroups.com
I'm also looking for a way to rename threads.  Currently we have multiple HttpServer objects within a single Java server (JVM) which means that we have multiple threads named "vert.x-eventloop-thread-0". Obviously, this is subpar when it comes to understanding what thread is doing what. I'd like to prefix these with some user-provided value so that you can tell them apart.

Tim Fox

unread,
Oct 17, 2013, 11:06:33 AM10/17/13
to ve...@googlegroups.com
On 17/10/13 16:01, Ian Rose wrote:
I'm also looking for a way to rename threads.  Currently we have multiple HttpServer objects within a single Java server (JVM) which means that we have multiple threads named "vert.x-eventloop-thread-0".

You shouldn't have more than one thread with that name unless you have embedded multiple Vertx objects in a single JVM which doesn't seem right to me.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages