Vertx 3.0 multiple thread http server

994 views
Skip to first unread message

Giang Tran

unread,
Jul 22, 2015, 12:03:35 AM7/22/15
to vert.x
Hi! 
I'm test a simple http server:

Vertx vertx = Vertx.vertx(new VertxOptions().setWorkerPoolSize(8));
 HttpServer server = vertx.createHttpServer();
 server.requestHandler(request -> {
 HttpServerResponse resp = request.response();
 resp.putHeader("Content-Type", "text/plain");
 resp.end("OK");
 });

A benchnark on this server show that it still use only single core to handle request, how do I make it use multiple core?

stream liu

unread,
Jul 22, 2015, 12:08:16 AM7/22/15
to ve...@googlegroups.com
`vertx run Your.java -instances 4`
`vertx run YourClass -instances 4`

more detail could be found vertx cmd in terminal

--
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 http://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/b925c090-92af-451a-acf3-99ad42a18f97%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Giang Tran

unread,
Jul 22, 2015, 1:36:40 AM7/22/15
to vert.x
I don't use Vertical, I start it as standalone application, so I don't think program arguments will work.

stream liu

unread,
Jul 22, 2015, 1:59:04 AM7/22/15
to ve...@googlegroups.com
Well, my fault.

I don't think there are way to deploy multi instances in embed application :)

In fact, you can distribute your content of HttpRequest to other thread which you create it,  that is may way in my tool application.

or warp your httpServer with Verticle and using `vertx.deployVerticle()` to deploy it with `DeploymentOptions`.









Giang Tran

unread,
Jul 22, 2015, 3:02:44 AM7/22/15
to vert.x
thanks, wrap it with Verticle and set the number of Verticle instances is ok, 
but any one can explain the usage of `setWorkerPoolSize`, is it work in standalone app?

Julien Viet

unread,
Jul 22, 2015, 3:18:40 AM7/22/15
to ve...@googlegroups.com, Giang Tran
workerPoolSize only matters if you are doing blocking operations.

with this example, what matters is rather eventLoopSize : it configures the max number of threads that can be allowed to event loop.

when you deploy the http server verticle with a number of instance let’s say N, then you will have min(N, eventLoopSize) thread allowed for serving.

if you have N > eventLoopSize then some instances will share the event loop threads.

note that this is not like typical blocking webserver, a single thread in an event loop server can handle much more requests than the classical approach, so don’t configure this eventLoopSize as you would do for traditional web servers.

-- 
Julien Viet
Sent with Airmail

Giang Tran

unread,
Jul 22, 2015, 3:54:44 AM7/22/15
to vert.x
ok, tha'ts clear now Julien, I was confused that workerPoolSize is something similar to Netty worker-pool size : )
Reply all
Reply to author
Forward
0 new messages