jira-importer opened a new issue, #1238: URL: https://github.com/apache/httpcomponents-core/issues/1238
**[Nikola Bekcic](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=JIRAUSER281053)** opened **[HTTPCORE-702](https://issues.apache.org/jira/browse/HTTPCORE-702?redirect=false)** and commented ### Background To manage the life cycle and re-use HTTP connections we are using **PoolingHttpClientConnectionManager** with the maximum limit of connections defined on a per route basis as well as in total. Using PoolingHttpClientConnectionManager and built-in Java management utilities, I want to provide our users with the option to dynamically re-size the connection pool (up and/or down) at runtime without redeploying or restarting the application with a new configuration. ### Issue description During testing, we found that decreasing the maximum limit of connection per route does not have (an immediate) effect on the pool size i.e maximum number of connections per route is staying the same (potentially for a very long time). E.g. let's use only two routes where the default maximum connections per route are 10 and the maximum total is 20. At some point, the maximum number of connections per route will be riched and the number of allocated connections (available + leased) will be 10. Now, let's say that we need to decrease the maximum number of connections per route to 5, for any reason. Doing that by calling either _PoolingHttpClientConnectionManager#setDefaultMaxPerRoute(int)_ or _PoolingHttpClientConnectionManager#setMaxPerRoute(HttpRoute, int)_ will not change the pool size and the maximum number of connections per route will stay the same (potentially for a very long time). This is the sample of the pool stats printed after changing +maxPerRoute+ to 5: ``` {somehost1:8983={"available":4,"leased":6,"max":5,"pending":0}, somehost2:8080={"available":1,"leased":9,"max":5,"pending":2}} {somehost1:8983={"available":4,"leased":6,"max":5,"pending":0}, somehost2:8080={"available":0,"leased":10,"max":5,"pending":2}} {somehost1:8983={"available":5,"leased":5,"max":5,"pending":0}, somehost2:8080={"available":0,"leased":10,"max":5,"pending":4}} {somehost1:8983={"available":5,"leased":5,"max":5,"pending":0}, somehost2:8080={"available":0,"leased":10,"max":5,"pending":4}} {somehost1:8983={"available":7,"leased":3,"max":5,"pending":0}, somehost2:8080={"available":0,"leased":10,"max":5,"pending":5}} {somehost1:8983={"available":9,"leased":1,"max":5,"pending":0}, somehost2:8080={"available":0,"leased":10,"max":5,"pending":5}} {somehost1:8983={"available":9,"leased":1,"max":5,"pending":0}, somehost2:8080={"available":0,"leased":10,"max":5,"pending":6}} {somehost1:8983={"available":8,"leased":2,"max":5,"pending":0}, somehost2:8080={"available":0,"leased":10,"max":5,"pending":6}} {somehost1:8983={"available":9,"leased":1,"max":5,"pending":0}, somehost2:8080={"available":0,"leased":10,"max":5,"pending":6}} {somehost1:8983={"available":8,"leased":2,"max":5,"pending":0}, somehost2:8080={"available":0,"leased":10,"max":5,"pending":7}} {somehost1:8983={"available":8,"leased":2,"max":5,"pending":0}, somehost2:8080={"available":0,"leased":10,"max":5,"pending":6}} {somehost1:8983={"available":8,"leased":2,"max":5,"pending":0}, somehost2:8080={"available":0,"leased":10,"max":5,"pending":6}} {somehost1:8983={"available":9,"leased":1,"max":5,"pending":0}, somehost2:8080={"available":0,"leased":10,"max":5,"pending":6}} {somehost1:8983={"available":9,"leased":1,"max":5,"pending":0}, somehost2:8080={"available":1,"leased":9,"max":5,"pending":6}}} ``` As you can see, not only that the number of allocated connections per route is still 10, but also very often the number of leased connection is higher than 5. In my opinion, this is not what is expected and not really in favor of the principle of least surprise. --- **Affects:** 4.4.14 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
