2

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?

Michael P
  • 2,017
  • 3
  • 25
  • 33

1 Answers1

2

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.

Alexey Soshin
  • 16,718
  • 2
  • 31
  • 40
  • Alexey Soshin. Thanks for the response. I'm not sure how it works, if I have a hostname that resolves to 4 IP addresses. In that case, the connection cannot be reused for different destination IP addresses. How does that work? – Michael P Apr 09 '18 at 22:27
  • HttpClient doesn't care about IPs behind your hostname. If you specify same hostname, you'll get same value from cache. – Alexey Soshin Apr 11 '18 at 12:18
  • Alexey yes I understand that. And I can see that in the code. But what is the behavior then if there are 4 IP per host. A connection is IP:PORT -> IP:PORT not IP:PORT -> HOST:PORT. So if an hostname resolves to 4 IPs, and my connection pool size for the hostname is 1. What is the behavior? Is only one IP address going to be used? It it actually going to maintain 4 connections for that hostname although the connection pool size is 1? Will it drop 3/4 of the requests? – Michael P Apr 11 '18 at 21:39
  • Usually, your OS will provide you 1 IP out of 4 at random, and that's the IP that will be used until the connection is dropped by one of the sides. – Alexey Soshin Apr 12 '18 at 07:47