0

Due to some performance improvements we are trying to make to our system, I'm trying to understand how Vertx Webclient is actually non-blocking.

From my understanding, in regular old java, an http call using java.net (or maybe a regular HTTP client implementation), will acquire an http connection on a thread. While that http requests is fulfilled, that thread is blocked. If one configures a pool of 20 threads and executes 20 http requests, the pool will be exhausted.

However, this doesn't seems to be the case in Vertx. One can execute many http requests using Webclient in the event-loop without blocking it.

In short, I'd like to know how Vertx Webclient manages to avoid blocks? Does it delegate execution to a worker thread-pool? Does it use some low level technique? If it is not using a thread-pool, what's the limit of requests it can handle at the same time?

Docs seem to just explain its usage but now how it actually works: https://vertx.io/docs/vertx-web-client/java/#_using_the_web_client

Diego
  • 713
  • 5
  • 19
  • Well one way to figure it our would be to look at the source code. Have you tried that? – Stephen C Aug 07 '22 at 01:15
  • Based on the way that the Vertx Webclient API is structured, I can guess on how it is implemented. At the bottom level they probably use the NIO selector mechanism; see https://www.baeldung.com/java-nio-selector. But you can confirm this yourself by reading the source code. (No ... this doesn't entail a worker thread for each request or each connection ...) – Stephen C Aug 07 '22 at 01:21
  • @StephenC Thanks for the hint about NIO selector. That's good enough for me to get back on track. Actually, I did take a look at the sources but it is quite a big code-base and yeah, a bit lost there. Thanks! – Diego Aug 07 '22 at 01:40

0 Answers0