Hi Oleg, Below my test with just the interesting part of the traces:
1. PoolingAsyncClientConnectionManager with LAX concurrency policy, max_connections = 1 and pool_timeot = 1. Sending 2 simultaneous requests: 08:34:28.195 org.apache.hc.client5.http.impl.async.InternalHttpAsyncClient org.apache.hc.client5.http.impl.async.InternalHttpAsyncExecRuntime acquireEndpoint 103 ex-0000000002 acquiring endpoint (1 MILLISECONDS) 08:34:28.195 org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager lease 264 ex-0000000002 endpoint lease request (1 MILLISECONDS) [route: {}->http://receiver01:8080][total available: 0; route allocated: 0 of 1; total allocated: 0 of 0] 08:34:28.197 org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager$3$1 leaseCompleted 323 ex-0000000002 endpoint leased [route: {}->http://receiver01:8080][total available: 0; route allocated: 1 of 1; total allocated: 1 of 1] 08:34:28.197 org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager$3$1 leaseCompleted 327 ex-0000000002 acquired ep-0000000001 08:34:28.197 org.apache.hc.client5.http.impl.async.InternalHttpAsyncClient org.apache.hc.client5.http.impl.async.InternalHttpAsyncExecRuntime$1 completed 117 ex-0000000002 acquired endpoint ep-0000000001 08:34:28.198 org.apache.hc.client5.http.impl.async.InternalHttpAsyncClient org.apache.hc.client5.http.impl.async.InternalHttpAsyncExecRuntime acquireEndpoint 103 ex-0000000001 acquiring endpoint (1 MILLISECONDS) 08:34:28.198 org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager lease 264 ex-0000000001 endpoint lease request (1 MILLISECONDS) [route: {}->http://receiver01:8080][total available: 0; route allocated: 1 of 1; total allocated: 1 of 1] ( . . .) 08:48:51.451 org.apache.hc.client5.http.impl.async.InternalAbstractHttpAsyncClient org.apache.hc.client5.http.impl.async.InternalAbstractHttpAsyncClient$1 failed 319 ex-0000000003 request failed: Deadline: 2023-06-26T08:48:49.445+0000, -2006 MILLISECONDS overdue 08:48:51.451 org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager release 413 ep-0000000003 connection released [route: {}->http://receiver01:8080][total available: 1; route allocated: 1 of 1; total allocated: 1 of 1] It's OK, 1 request is sent OK and the another one fails because the max_connections was exceeded. 2. Now I modify the max_connections from 1 to 1000 on runtime. Sending 2 simultaneous requests: 08:36:30.093 org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager lease 264 ex-0000000004 endpoint lease request (1 MILLISECONDS) [route: {}->http://receiver01:8080][total available: 0; route allocated: 0 of 1; total allocated: 0 of 1] 08:36:30.093 org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager$3$1 leaseCompleted 323 ex-0000000004 endpoint leased [route: {}->http://receiver01:8080][total available: 0; route allocated: 1 of 1; total allocated: 1 of 1] 08:36:30.093 org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager lease 264 ex-0000000003 endpoint lease request (1 MILLISECONDS) [route: {}->http://receiver01:8080][total available: 0; route allocated: 0 of 1; total allocated: 0 of 1] ( . . . ) 08:36:32.099 org.apache.hc.client5.http.impl.async.InternalAbstractHttpAsyncClient org.apache.hc.client5.http.impl.async.InternalAbstractHttpAsyncClient$1 failed 319 ex-0000000003 request failed: Deadline: 2023-06-26T08:36:30.094+0000, -2005 MILLISECONDS overdue 08:36:32.099 org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager release 413 ep-0000000002 connection released [route: {}->http://receiver01:8080][total available: 1; route allocated: 1 of 1; total allocated: 1 of 1] Error, this update from 1 to 1000 is not reflected on runtime. 3. With the same parameters of point 2, now I restart the pool. Sending 2 simultaneous requests: 08:38:46.096 org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager lease 264 ex-0000000002 endpoint lease request (1 MILLISECONDS) [route: {}->http://receiver01:8080][total available: 0; route allocated: 0 of 1000; total allocated: 0 of 0] 08:38:46.096 org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager lease 264 ex-0000000001 endpoint lease request (1 MILLISECONDS) [route: {}->http://receiver01:8080][total available: 0; route allocated: 0 of 1000; total allocated: 0 of 0] 08:38:46.096 org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager$3$1 leaseCompleted 323 ex-0000000002 endpoint leased [route: {}->http://receiver01:8080][total available: 0; route allocated: 2 of 1000; total allocated: 2 of 1000] 08:38:46.096 org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager$3$1 leaseCompleted 327 ex-0000000002 acquired ep-0000000001 08:38:46.096 org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager$3$1 leaseCompleted 323 ex-0000000001 endpoint leased [route: {}->http://receiver01:8080][total available: 0; route allocated: 2 of 1000; total allocated: 2 of 1000] 08:38:46.096 org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager$3$1 leaseCompleted 327 ex-0000000001 acquired ep-0000000002 ( . . . ) 08:38:48.123 org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager release 413 ep-0000000001 connection released [route: {}->http://receiver01:8080][total available: 1; route allocated: 2 of 1000; total allocated: 2 of 1000] 08:38:48.123 org.apache.hc.client5.http.impl.async.InternalHttpAsyncClient org.apache.hc.client5.http.impl.async.HttpAsyncClientProtocolNegotiationStarter$1 onExchangeComplete 150 c-0000000000 Connection is kept alive 08:38:48.124 org.apache.hc.client5.http.impl.async.InternalAbstractHttpAsyncClient org.apache.hc.client5.http.impl.async.InternalAbstractHttpAsyncClient$1 completed 306 ex-0000000001 message exchange successfully completed 08:38:48.124 org.apache.hc.client5.http.impl.async.InternalHttpAsyncClient org.apache.hc.client5.http.impl.async.InternalHttpAsyncExecRuntime releaseEndpoint 157 ep-0000000002 releasing valid endpoint 08:38:48.124 org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager release 388 ep-0000000002 releasing endpoint 08:38:48.124 org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager release 404 ep-0000000002 connection c-0000000001 can be kept alive for 100 MILLISECONDS 08:38:48.125 org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager release 413 ep-0000000002 connection released [route: {}->http://receiver01:8080][total available: 2; route allocated: 2 of 1000; total allocated: 2 of 1000] 08:38:48.125 org.apache.hc.client5.http.impl.async.InternalHttpAsyncClient org.apache.hc.client5.http.impl.async.HttpAsyncClientProtocolNegotiationStarter$1 onExchangeComplete 150 c-0000000001 Connection is kept alive It's OK. Now I was wondering if all this stuff also fails if I change the concurrency policy from LAX to STRICT. Below the results: 4. Same parameters of point 2 and 3 and pool restarted: 08:47:40.886 org.apache.hc.client5.http.impl.async.InternalHttpAsyncClient org.apache.hc.client5.http.impl.async.InternalHttpAsyncExecRuntime acquireEndpoint 103 ex-0000000001 acquiring endpoint (1 MILLISECONDS) 08:47:40.886 org.apache.hc.client5.http.impl.async.InternalHttpAsyncClient org.apache.hc.client5.http.impl.async.InternalHttpAsyncExecRuntime acquireEndpoint 103 ex-0000000002 acquiring endpoint (1 MILLISECONDS) 08:47:40.887 org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager lease 264 ex-0000000001 endpoint lease request (1 MILLISECONDS) [route: {}->http://receiver01:8080][total available: 0; route allocated: 0 of 1000; total allocated: 0 of 1000] 08:47:40.887 org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager lease 264 ex-0000000002 endpoint lease request (1 MILLISECONDS) [route: {}->http://receiver01:8080][total available: 0; route allocated: 0 of 1000; total allocated: 0 of 1000] 08:47:40.888 org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager$3$1 leaseCompleted 323 ex-0000000001 endpoint leased [route: {}->http://receiver01:8080][total available: 0; route allocated: 2 of 1000; total allocated: 2 of 1000] 08:47:40.888 org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager$3$1 leaseCompleted 323 ex-0000000002 endpoint leased [route: {}->http://receiver01:8080][total available: 0; route allocated: 2 of 1000; total allocated: 2 of 1000] 08:47:40.888 org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager$3$1 leaseCompleted 327 ex-0000000002 acquired ep-0000000001 08:47:40.888 org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager$3$1 leaseCompleted 327 ex-0000000001 acquired ep-0000000002 ( . . . ) 08:47:42.911 org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager release 413 ep-0000000002 connection released [route: {}->http://receiver01:8080][total available: 1; route allocated: 2 of 1000; total allocated: 2 of 1000] 08:47:42.911 org.apache.hc.client5.http.impl.async.InternalHttpAsyncClient org.apache.hc.client5.http.impl.async.HttpAsyncClientProtocolNegotiationStarter$1 onExchangeComplete 150 c-0000000001 Connection is kept alive 08:47:42.912 org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager release 413 ep-0000000001 connection released [route: {}->http://receiver01:8080][total available: 2; route allocated: 2 of 1000; total allocated: 2 of 1000] 08:47:42.912 org.apache.hc.client5.http.impl.async.InternalHttpAsyncClient org.apache.hc.client5.http.impl.async.HttpAsyncClientProtocolNegotiationStarter$1 onExchangeComplete 150 c-0000000000 Connection is kept alive It's OK. 5. Now I modify the max_connections from 1000 to 1 on runtime. Sending 2 simultaneous requests: 08:48:49.444 org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager lease 264 ex-0000000004 endpoint lease request (1 MILLISECONDS) [route: {}->http://receiver01:8080][total available: 0; route allocated: 0 of 1; total allocated: 0 of 1] 08:48:49.444 org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager lease 264 ex-0000000003 endpoint lease request (1 MILLISECONDS) [route: {}->http://receiver01:8080][total available: 0; route allocated: 0 of 1; total allocated: 0 of 1] 08:48:49.444 org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager$3$1 leaseCompleted 323 ex-0000000004 endpoint leased [route: {}->http://receiver01:8080][total available: 0; route allocated: 1 of 1; total allocated: 1 of 1] ( . . . ) 08:48:51.449 org.apache.hc.client5.http.impl.async.InternalHttpAsyncClient org.apache.hc.client5.http.impl.async.InternalHttpAsyncExecRuntime releaseEndpoint 157 ep-0000000003 releasing valid endpoint 08:48:51.449 org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager release 388 ep-0000000003 releasing endpoint 08:48:51.449 org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager release 404 ep-0000000003 connection c-0000000002 can be kept alive for 100 MILLISECONDS 08:48:51.451 org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager$3$1 failed 335 ex-0000000003 endpoint lease failed 08:48:51.451 org.apache.hc.client5.http.impl.async.InternalAbstractHttpAsyncClient org.apache.hc.client5.http.impl.async.InternalAbstractHttpAsyncClient$1 failed 319 ex-0000000003 request failed: Deadline: 2023-06-26T08:48:49.445+0000, -2006 MILLISECONDS overdue 08:48:51.451 org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager release 413 ep-0000000003 connection released [route: {}->http://receiver01:8080][total available: 1; route allocated: 1 of 1; total allocated: 1 of 1] 08:48:51.451 org.apache.hc.client5.http.impl.async.InternalHttpAsyncClient org.apache.hc.client5.http.impl.async.HttpAsyncClientProtocolNegotiationStarter$1 onExchangeComplete 150 c-0000000002 Connection is kept alive So it works perfectly, 1 request sent OK and the another fails because max_connections was exceeded. It seems that changing the maxConnectionPerRoute does not work on runtime ONLY when the concurrency policy is LAX. Anyways maybe I'm doing something wrong ... just let me know what you think. Thanks, Joan. -----Original Message----- From: Oleg Kalnichevski <ol...@apache.org> Sent: Friday, June 23, 2023 12:04 PM To: HttpClient User Discussion <httpclient-users@hc.apache.org> Subject: Re: Question about max connections On Fri, 2023-06-23 at 11:52 +0200, Joan grupoventus wrote: > Hi Oleg, > > In the lax mode the pool manager supports the per route max limit, but > not total max limit. The total max setting has no effect. > --> Thanks, I can see that when I print the values, the total max is > always 0. > > But the question is if I can modify the per route max limit on the > fly, or after modifying it I need to restart the pool to apply the new > value. > One can modify the per route max at runtime. Oleg > Thanks, > > Joan. > > -----Original Message----- > From: Oleg Kalnichevski <ol...@apache.org> > Sent: Friday, June 23, 2023 11:28 AM > To: HttpClient User Discussion <httpclient-users@hc.apache.org> > Subject: Re: Question about max connections > > On Fri, 2023-06-23 at 11:23 +0200, Joan grupoventus wrote: > > Hello, > > > > We have an async http pool with LAX concurrency (httpclient 5.2.1): > > this.phccm = > > PoolingAsyncClientConnectionManagerBuilder.create().setPoolConcurre > > nc > > yPolicy(PoolConcurrencyPolicy.LAX).build(); > > > > We set the max connections in this way: > > public void setMaxConnections(int maxConnections) { > > this.phccm.setMaxTotal(maxConnections); > > this.phccm.setDefaultMaxPerRoute(maxConnections); > > } > > > > I'm not sure if we are having an issue with this, but before > > starting to analyse http traces just one question: will it work to > > call the 'setMaxConnections' method to modify these parameters on > > the fly, or must I restart the pool to apply the new values? > > > > Thanks, > > > > Joan. > > > > Hi Joan > > In the lax mode the pool manager supports the per route max limit, but > not total max limit. The total max setting has no effect. > > Oleg > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org > For additional commands, e-mail: httpclient-users-h...@hc.apache.org > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org > For additional commands, e-mail: httpclient-users-h...@hc.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org For additional commands, e-mail: httpclient-users-h...@hc.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org For additional commands, e-mail: httpclient-users-h...@hc.apache.org