How can I increase per host concurrency with HttpClient?

475 views
Skip to first unread message

Ashish Datta

unread,
Jun 5, 2018, 12:09:26 AM6/5/18
to vert.x
My use case seems fairly typical but I can't seem to find a working example. I'm using Vert.x 3.5.0 with -instances=3

I have a Vert.x web server which services user requests and in doing so has to ping a 3rd party fraud service with their phone+email. I'm making these requests on a verticle through the EventBus but since all the requests are to the same domain and host it looks like I'll always only have a max of 3 (1 per verticle) connections open to the host. This class seems to be gone in master but it looks like https://gist.github.com/adatta02/2229da27d3d629981d3ba1be53bc8884#file-connectionmanager-java-L145 is what's limiting that. And seems independent of any HttpClientOptions being set like setMaxPoolSize()

So my question is how can I scale up the number of connections HttpClient (or WebClient) will make to a host short of boosting the number of verticles? Over half of the requests hitting the web server require a request to the 3rd party service so I'm trying to get to something like long lived ~25-30 HTTP connections to the service to boost my overall throughput since these verification requests have become a bottleneck in servicing traffic.

Thanks!

Julien Viet

unread,
Jun 5, 2018, 3:09:29 AM6/5/18
to ve...@googlegroups.com
Hi,

we recommend to use several clients in this case.

there is no overhead for doing this (as a client is very lightweight and is basically a map of endpoint where each endpoint contains a pool of connections)

Julien

--
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/982b5893-ceaf-42a6-9aa8-5ac4e5dbf27e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Julien Viet

unread,
Jun 5, 2018, 5:36:23 AM6/5/18
to ve...@googlegroups.com
Hi,

actually I'm not sure I understood well your question, because this event bus usage is confusing

can you rephrase it ?

the HttpClient currently uses up to N connection per host:port (for HTTP/1.1) as configured by maxPoolSize

if you deploy a verticle that configures this client M times, then you get N x M max connection.

Julien

On 5 Jun 2018, at 06:09, Ashish Datta <adat...@gmail.com> wrote:

Ashish Datta

unread,
Jun 5, 2018, 11:41:33 AM6/5/18
to vert.x
Ah my fault, I actually inherited this codebase and didn't realize that the developers are actually creating a client per request. I think I'm hitting another issue which I'm not sure how to describe.

is basically what they're doing.

That project actually will reproduce this issue. Requests to the "fast" endpoint are fine:

<html><body><h1>OK</h1></body></html>

But if I make several requests to http://app.s5srv.com/slow.php which times out and then make a request to the "fast" endpoint I seem to get a TimeoutException even thought I would assume the HttpClient instances aren't shared.

<html><body><h1>url
ashish@loki:~$ curl http://localhost:8080/test-fast

You'll notice the vertx process outputs:

ERROR
java.util.concurrent.TimeoutException: The timeout period of 1000ms has been exceeded while executing GET /slow.php?q=notslow&i=REQUESTED for host app.s5srv.com
    at io.vertx.core.http.impl.HttpClientRequestBase.timeout(HttpClientRequestBase.java:178)
    at io.vertx.core.http.impl.HttpClientRequestBase.handleTimeout(HttpClientRequestBase.java:163)
    at io.vertx.core.http.impl.HttpClientRequestBase.lambda$setTimeout$0(HttpClientRequestBase.java:121)
    at io.vertx.core.impl.VertxImpl$InternalTimerHandler.handle(VertxImpl.java:885)
    at io.vertx.core.impl.VertxImpl$InternalTimerHandler.handle(VertxImpl.java:844)
    at io.vertx.core.impl.ContextImpl.lambda$wrapTask$2(ContextImpl.java:339)
    at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
    at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:463)
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:886)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.lang.Thread.run(Thread.java:745)
On fast got: ERROR

So I'm not clear on what's going on.

Thanks!
Reply all
Reply to author
Forward
0 new messages