I am using Apache HTTP Client for connection pooling during my REST API calls into certain web services.
Strange thing is that in spite of me using HTTP Connection Pooling there are no gain in my performance.
I am using Apache HTTP Client to connect to my web services, and the code is as follows from there documentation :
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
cm.setMaxTotal(200);
cm.setDefaultMaxPerRoute(20);
HttpHost host = new HttpHost("abc.com", 80);
cm.setMaxPerRoute(new HttpRoute(host), 50);
CloseableHttpClient httpClient = HttpClients.custom()
.setConnectionManager(cm)
.build();
I am using Spring's RestTemplate
to wrap around the HttpClient
implemenation of Apache using Spring's HttpComponentsClientHttpRequestFactory
.
But even if I use no connection pooling ie. use the SimpleClientHttpRequestFactory
of Spring, I get no performance advantage.
My connections still take the same amount of time to complete.
Is what I have done the correct way to implement HTTP Connection Pooling? Am I doing something wrong?
Please let me know if any further info is required from my side.
PoolingHttpClientConnectionManager
is used for multi-threading case, as it will help multiple connections concurrently. I might be wrong here, can someone please explain this correctly? – Addieaddiego