Open f1llon opened 1 week ago
Good day, @f1llon ! This option sets apache client pool configuration:
setDefaultMaxPerRoute
setMaxTotal
See https://hc.apache.org/httpcomponents-client-5.3.x/current/httpclient5/apidocs/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManager.html I agree that documentation doesn't explain it.
Hey, @chernser. Thank you for your attention to this issue!
As I mentioned, a new instance of the ApacheHttpConnectionImpl
is created for each connection. A new PoolingHttpClientConnectionManager
is created under the hood. The MAX_OPEN_CONNECTIONS property is used to setMaxTotal
and setDefaultMaxPerRoute
, see sources.
Thus, we have the same number of PoolingHttpClientConnectionManager
s as many connections we have.
It seems more logical to me to set up a singleton PoolingHttpClientConnectionManager
and reuse it for each connection.
Or maybe I misunderstood something.
@f1llon you are right. I just wanted to mention that initial purpose of the setting MAX_OPEN_CONNECTIONS is to pass configuration to the Apache HC. Current behavior of the CH Client is not correct and we will fix it.
Describe the bug
It seems that max_open_connections config option doesn't work as expected - it doesn't limit the number of opened connections.
As far from I see from the driver codebase, a new instance of the ApacheHttpConnectionImpl is created for each connection and the config option is used inside. Thus it has no impact on the real number of opened connections.
Steps to reproduce
Expected behavior
the number of parallel requests is limited by MAX_OPEN_CONNECTIONS, other requests are waiting in a queue
Code example
see full example here
Error log
see log here
take a look at messages like - "[total available: 0; route allocated: 1 of 3; total allocated: 1 of 3]" it's always
1 of N
Dependencies
see project dependencies here