In a spring boot application, I am creating a connection pool using PoolingHttpClientConnectonManager as follows:
@Bean
public PoolingHttpClientConnectionManager createCM() {
PoolingHttpClientConnectionManager pcm = new PoolingHttpClientConnectionManager();
poolingHttpClientConnectionManager.setMaxTotal(100);
poolingHttpClientConnectionManager.setDefaultMaxPerRoute(100);
return pcm;
}
Since I have only one route, I keep the values of setMaxTotal and setDefaultMaxPerRoute same.
The underlying httpClient configuration is as follows:
@Bean
public CloseableHttpClient createHttpClient(PoolingHttpClientConnectionManager pcm, RequestConfig rc) {
CloseableHttpClient httpClient = HttpClientBuilder
.create()
.setConnectionManager(pcm)
.setDefaultRequestConfig(rc)
.build();
return httpClient;
}
Now the problem is that when I stress test my application under very heavy loads to see how my connection pool would behave, I don't see the expected. I monitor the threads of the application using jConsole and every single time I see only 2 connection pool threads in runnable state namely https-jsse-nio-80-ClientPoller-1 and https-jsse-nio-80-ClientPoller-2.
I presume under heavy loads of the order of 1500 requests per second, it should have done it by more than 2 (default) connections in the pool. wondering what's going wrong or if my configuration is not correct.