Discussion:
Releasing a Pooled connection to pool - socket reuse address performance.
j***@redhat.com
2018-11-05 15:56:53 UTC
Permalink
Hi,
I am attempting to use the client API. Following the documentation to
combine....

Pooling Connection Manager
+
Multithreaded request execution
+
keep-alive
+
re-use socket address

I want to know how the api should be used to re-use the underlying
socket. With the aim to avoid sockets in CLOSE_WAIT waiting to timeout.
My use case is using httpcomponents to benchmark a server.

The example code in 2.4. Multithreaded request execution shows the
CloseableHttpResponse.close() method being called. I find this closes
the socket on the managed connection respone. That's because
org.apache.http.impl.execchain.ConnectionHolder.close() releases the
managed connection but ignores the configured boolean value of
ConnectionHolder.reusable.

Avoiding the call to CloseableHttpResponse.close() means the
underlying connection is never released to the pool.

To me this seems broken.

I'd expect to find a visible releaseConnection method on the response
object. The body honouring how to handle the underlying resources and
the managed connection released to the pool.

I looked for an example but found none. How is this supposed to work ?

Regards,
Jeremy Whiting



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-***@hc.apache.org
For additional commands, e-mail: httpclient-users-***@hc.apache.org
Oleg Kalnichevski
2018-11-05 16:19:21 UTC
Permalink
Post by j***@redhat.com
Hi,
I am attempting to use the client API. Following the documentation to
combine....
Pooling Connection Manager
+
Multithreaded request execution
+
keep-alive
+
re-use socket address
I want to know how the api should be used to re-use the underlying
socket. With the aim to avoid sockets in CLOSE_WAIT waiting to
timeout.
My use case is using httpcomponents to benchmark a server.
The example code in 2.4. Multithreaded request execution shows the
CloseableHttpResponse.close() method being called. I find this closes
the socket on the managed connection respone. That's because
org.apache.http.impl.execchain.ConnectionHolder.close() releases the
managed connection but ignores the configured boolean value of
ConnectionHolder.reusable.
Avoiding the call to CloseableHttpResponse.close() means the
underlying connection is never released to the pool.
This is incorrect. The underlying connections gets released back to the
connection pool as soon as the response message content gets fully
consumed (processed). CloseableHttpResponse#close aborts the connection
only when the client code fails to consume the response message content
in its entirety. For details see:

http://hc.apache.org/httpcomponents-client-4.5.x/tutorial/html/fundamentals.html#d5e145

Oleg
Post by j***@redhat.com
To me this seems broken.
I'd expect to find a visible releaseConnection method on the
response
object. The body honouring how to handle the underlying resources and
the managed connection released to the pool.
I looked for an example but found none. How is this supposed to work ?
Regards,
Jeremy Whiting
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-***@hc.apache.org
For additional commands, e-mail: httpclient-users-***@hc.apache.org
j***@redhat.com
2018-11-07 08:46:34 UTC
Permalink
Thanks for pointing that out. I can confirm my code is handling the
responses well now.

Jeremy
Post by Oleg Kalnichevski
Post by j***@redhat.com
Hi,
I am attempting to use the client API. Following the documentation to
combine....
Pooling Connection Manager
+
Multithreaded request execution
+
keep-alive
+
re-use socket address
I want to know how the api should be used to re-use the underlying
socket. With the aim to avoid sockets in CLOSE_WAIT waiting to timeout.
My use case is using httpcomponents to benchmark a server.
The example code in 2.4. Multithreaded request execution shows the
CloseableHttpResponse.close() method being called. I find this closes
the socket on the managed connection respone. That's because
org.apache.http.impl.execchain.ConnectionHolder.close() releases the
managed connection but ignores the configured boolean value of
ConnectionHolder.reusable.
Avoiding the call to CloseableHttpResponse.close() means the
underlying connection is never released to the pool.
This is incorrect. The underlying connections gets released back to the
connection pool as soon as the response message content gets fully
consumed (processed). CloseableHttpResponse#close aborts the
connection
only when the client code fails to consume the response message content
http://hc.apache.org/httpcomponents-client-4.5.x/tutorial/html/fundamentals.html#d5e145
Post by Oleg Kalnichevski
Oleg
Post by j***@redhat.com
To me this seems broken.
I'd expect to find a visible releaseConnection method on the response
object. The body honouring how to handle the underlying resources and
the managed connection released to the pool.
I looked for an example but found none. How is this supposed to
work
?
Regards,
Jeremy Whiting
-----------------------------------------------------------------
----
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-***@hc.apache.org
For additional commands, e-mail: httpclient-users-***@hc.apache.org
Loading...