Do we need to set setThreadingModel(ThreadingModel.WORKER) for executeBlocking to be executed by worker thread

31 views
Skip to first unread message

Sachin Mittal

unread,
Jun 24, 2025, 1:43:41 AMJun 24
to vert.x
Hi,
In my vert.x web application I have multiple event loop threads and also worker threads.

I was thinking of add a blocking handler to my POST requests, so it gets handled by worker threads and my event loop is always free.
router.post().blockingHandler(new PostHandler(...));

My post requests parses json and sends it to a Kafka topic.

Now for the above code to be executed on work thread when deploying the verticle do I need set the following options in my launcher:

deploymentOptions.setInstances(...).setThreadingModel(ThreadingModel.WORKER);

If this is not needed then why do we need threading model and default of which I suppose is set as: ThreadingModel.EVENT_LOOP

Thanks
Sachin

Thomas SEGISMONT

unread,
Jun 30, 2025, 10:09:02 AMJun 30
to ve...@googlegroups.com
Hi,

When you set a blockingHander on a Vert.x Web route, Vert.x wraps the execution of the handler with Vertx.executeBlocking
So it doesn't matter if the verticle threading model is event loop or worker.

When you set the threading model to WORKER, it means every event in your verticle will you be handled by a worker instead of the event loop.

Thanks,
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.
To view this discussion, visit https://groups.google.com/d/msgid/vertx/438ba054-1c46-4364-9936-777f606b5468n%40googlegroups.com.

Sachin Mittal

unread,
Jul 9, 2025, 11:33:05 PMJul 9
to ve...@googlegroups.com
So I have a general query here. We have upgraded to Vertx 5 and Java 22.
Which threading model is most performant. We run a cluster of vertx applications and the goal is to handle million requests per second.
This vertx application extracts the json body and pushes the data to Kafka.

So should we go with default threading model and use a blocking handler for certain processing or should we change it to a worker or virtual threads model.

Does the new virtual threads model have better performance?

Thanks
Sachin


You received this message because you are subscribed to a topic in the Google Groups "vert.x" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vertx/viLBEdHCDmE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vertx+un...@googlegroups.com.
To view this discussion, visit https://groups.google.com/d/msgid/vertx/CACiEr_Q4PEow1DXfN3%3Db74umOgqEKyiLt3KAS1pdzEYS6Ge59w%40mail.gmail.com.

Thomas SEGISMONT

unread,
Jul 10, 2025, 11:01:25 AMJul 10
to ve...@googlegroups.com
To get a definitive answer about performance, you have to benchmark your own use case.

In general, the event loop model should help you squeeze every drop out of your machine. But for some use cases the virtual thread model is sufficient and can simplify your implementation.

It's a trade-off, you have to make your own choices.

You can read this article from our colleagues (it's about Quarkus but the underlying engine is Vert.x)

Reply all
Reply to author
Forward
0 new messages