Michael P
Michael P

Reputation: 2067

Vert.x HTTP Client creates more connections than the MaxPoolSize

I have 8 verticle in my application. Each Verticle is on a separate thread. Each Verticle has an WebClient ( Vert.x HTTP client) I am setting the MaxPoolSize to 10. WebClientOptions webClientOptions = new WebClientOptions() .setMaxPoolSize(10) However when I checked with

/usr/sbin/ss -o state established -tn  | tail -n +2  | awk '{ print $4 }' | sort |uniq -c | sort -n

On a production host, I can see that there are more than 10 connections per IP:Port.

Question 1: Is MaxPoolSize global for the entire application or per verticle. So for X.X.X.X:Y can I created 10 connections or 80 from my application?

Question 2: When I send a request to a host that has more than one IP in its DNS, would the connection pool be per host, or per IP? For example gogo.com resolves to 2 IP addresses. Can I create 10 connections to gogo.com 20?

Upvotes: 2

Views: 3590

Answers (1)

Alexey Soshin
Alexey Soshin

Reputation: 17701

To understand how it works, let's look at the actual code of HttpClientImpl.
You would be most interested in this part:

https://github.com/eclipse/vert.x/blob/master/src/main/java/io/vertx/core/http/impl/HttpClientImpl.java#L161

As you can see, each WebClient/HttpClient has its own connection pool. So, 8 clients with maxPool of 10 will result in 80 connections.

As to you second question, the connection is per host, not IP, as far as I know and can see from the code. So you'll always be able to establish up to 10 connections: https://github.com/eclipse/vert.x/blob/39c22d657d2daf640cfbdd8c63e5110fc73474fb/src/main/java/io/vertx/core/http/impl/ConnectionManager.java#L56

Footnote: this is all true only if you don't touch http2MaxPoolSize. If you do, the math is a bit different.

Upvotes: 2

Related Questions