Reputation: 1
I'm using PoolingHttpClientConnectionManager to configure how many concurrent requests I could send to servers, my code looks like
private RestTemplate createRestTemplate(HttpHost proxy) throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
CloseableHttpClient httpClient;
PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager();
connManager.setMaxTotal(20);
connManager.setDefaultMaxPerRoute(10);
and I enabled logs in logback config like
<logger name="org.apache.http.impl.conn.PoolingHttpClientConnectionManager" level="DEBUG"/>
When testing, logs look like
h.i.c.PoolingHttpClientConnectionManager : Connection request: [route: {tls}->http://xxxxx][total available: 0; route allocated: 1 of 10; total allocated: 1 of 20]
I can guess the meaning of route allocated
and total allocated
, but wonder what does it mean for total available
? It doesn't make sense for available connections or something, please let me know if there's a doc about this, thanks.
I can't find online doc about this
Upvotes: 0
Views: 1772
Reputation: 11
The log message you provided is from the PoolingHttpClientConnectionManager class of Apache HttpClient, and while it doesn't have an official, detailed public documentation for this log message format, I can provide some context to help you understand what these values typically represent:
Total Available: This typically represents the total number of connections that are currently available in the connection pool for all routes. In your log message, it shows "0," which means that there are no available connections at that moment.
Route Allocated: This represents the number of connections that are currently allocated for a specific route. A "route" in this context typically refers to a specific combination of target host and proxy (if any). For example, in your log, the route is shown as "{tls}->http://xxxxx," which implies it's a TLS (HTTPS) connection going through an HTTP proxy.
Total Allocated: This represents the total number of connections that are currently allocated across all routes. In your log message, it shows "1," which means that there's one connection currently in use.
To give you a better idea, let's break down your log message:
"Connection request: [route: {tls}->http://xxxxx][total available: 0; route allocated: 1 of 10; total allocated: 1 of 20]"
Total Available: 0 - There are currently no available connections in the pool for all routes.
Route Allocated: 1 of 10 - For the specific route "{tls}->http://xxxxx," one connection has been allocated, and you can allocate up to 10 connections for this route.
Total Allocated: 1 of 20 - Across all routes, there is one connection currently allocated, and you can allocate up to 20 connections in total. In your configuration, you've set a maximum total of 20 connections and a maximum of 10 connections per route. The purpose of these settings is to limit the number of concurrent connections to a specific host or route and to the total number of connections in the pool to prevent overloading the server or exhausting system resources.
While you won't find detailed public documentation for this log message format, you can generally rely on these interpretations to understand the log messages generated by the PoolingHttpClientConnectionManager.
Upvotes: 1