Re: [jira] Commented: (HTTPCLIENT-1012) ThreadSafeClientConnManager Connection pool leak issue

2010-10-14 Thread Oleg Kalnichevski
On Thu, 2010-10-14 at 07:39 -0700, SomuReddy wrote:
> 
> Thanks Oleg, hope I'm replying now from right place.,
> 
> Few things, we are using the F5 load balancer between back end servers and
> our application. So our application is going to send http request to load
> balancer not directly to back end server.
> 
> So do we need to take any special care when we are using the HttpClient to
> send http request to Load Balancer in terms of connection pool?
> 

Nothing I can think of.


> FYI.. Some times we won't get the response from back end servers due to some
> data problems so we see lot of 500 status exceptions from servers. when we
> got bunch of these exceptions.. we are seeing the 'Timeout waiting for
> connection' because there is no free connection left in pool. though we are
> doing abort() and consumeContent() when we got any exception..  
> 

You can monitor activities of the connection manager by turning on just
a small number of log categories as described in the logging guide. It
should be fairly easy to see whether or not the connection gets released
back to the pool in case of an exception.


> but we never use closeExpiryConnections(), is it worth to call this method
> when we got exception?
> 

I do not think so.


> can you suggest any other things we need to take care when we are using  the
> Http4.0.3 Cooonectionpool (ThreadSafeClientConnManager)  to work efficiency
> manner?
> 
> Thanks..
> 
> 

Make sure your thread pool and the connection pool are sized
consistently. If you have too many worker threads contesting for a much
smaller number of connections in the pool you are bound to have
ConnectionPoolTimeoutException

Hope this helps

Oleg



-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [jira] Commented: (HTTPCLIENT-1012) ThreadSafeClientConnManager Connection pool leak issue

2010-10-14 Thread SomuReddy


Thanks Oleg, hope I'm replying now from right place.,

Few things, we are using the F5 load balancer between back end servers and
our application. So our application is going to send http request to load
balancer not directly to back end server.

So do we need to take any special care when we are using the HttpClient to
send http request to Load Balancer in terms of connection pool?

FYI.. Some times we won't get the response from back end servers due to some
data problems so we see lot of 500 status exceptions from servers. when we
got bunch of these exceptions.. we are seeing the 'Timeout waiting for
connection' because there is no free connection left in pool. though we are
doing abort() and consumeContent() when we got any exception..  

but we never use closeExpiryConnections(), is it worth to call this method
when we got exception?

can you suggest any other things we need to take care when we are using  the
Http4.0.3 Cooonectionpool (ThreadSafeClientConnManager)  to work efficiency
manner?

Thanks..





JIRA [email protected] wrote:
> 
> 
> [
> https://issues.apache.org/jira/browse/HTTPCLIENT-1012?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12920738#action_12920738
> ] 
> 
> Oleg Kalnichevski commented on HTTPCLIENT-1012:
> ---
> 
>> My question is there if any socket connection exception happens while
>> executing the Http Request then the response object
>>  is null so there is nothing to consume the content, what happens in this
>> case.. 
> 
> connection will be shut down and automaticaly released back to the pool
> 
>> will that connection is going back to the pool?
> 
> Yes, it will
> 
>> If I close the expiry connection using the closeExpiredConnections()
>> method , will it create new connection for that?? 
> 
> Those connections will be evicted from the pool and new connections will
> be created when needed
> 
>> I don't understand why it says, connection Closed, connection shut down
>> and released connection is not reusable?
> 
> The log is somewhat noisy. Basically if a connection throws an exception
> (including socket timeout) in the course of HTTP request execution
> HttpClient shuts down that connection as it may be left in a inconsistent
> state and therefore considered non-reusable.
> 
> _Please_ post your questions to the HttpClient user list. Jira is not a
> support forum.
> 
> Oleg
> 
>> ThreadSafeClientConnManager Connection pool  leak issue
>> ---
>>
>> Key: HTTPCLIENT-1012
>> URL:
>> https://issues.apache.org/jira/browse/HTTPCLIENT-1012
>> Project: HttpComponents HttpClient
>>  Issue Type: Bug
>>  Components: HttpConn
>>Affects Versions: 4.0.3
>>Reporter: chowdareddy somu
>>
>> Hi,
>> We are using the HttpClient4.0.3(latest) version for our application
>> where we need to serve the http request to our web app by calling the
>> underlying services.
>> Application gets an average 50 threads at a time and we are maintaining
>> the connection pool  on per host basis. we configured the following
>> HttpParam values.. And we are calling the abort() and consumeContent()
>> methods if there are any exceptions due to backed service problem, and
>> for success requests we are extracting the response using the get content
>> method( InputStream is = httpResponse.getEntity().getContent())
>> Application runs contionusly for 3 to 4 hrs fine, after that its getting
>> the out of connections and it throws below exception..
>> Config Values
>> http.connection.timeout = 5000
>> http.socket.timeout = 30
>> http.conn-manager.timeout = 1000
>> http.conn-manager.max-per-route = 100
>> http.conn-manager.max-total = 100
>> private static HttpConnectionManagerFactory instance = null;
>>  private Map map = new HashMap> ClientConnectionManager>();
>>  private HttpConnectionManagerFactory() {
>>  }
>>  public static synchronized HttpConnectionManagerFactory getInstance() {
>>  if (instance == null) {
>>  instance = new HttpConnectionManagerFactory();
>>  }
>>  return instance;
>>  }
>>  public synchronized ClientConnectionManager getConnectionManager(URI
>> uri) {
>>  if (!map.containsKey(uri.getHost())) {
>>  HttpParams params = 
>> HttpProperties.getInstance().getHttpParams(uri);
>>  SchemeRegistry registry = new SchemeRegistry();
>>  Scheme http = new Scheme("http",
>> PlainSocketFactory.getSocketFactory(), 80);
>>  registry.register(http);
>>  map.put(uri.getHost(), new 
>> ThreadSafeClientConnManager(params,
>> registry));
>>  }
>>  return map.get(uri.getHost());
>>  }
>> public HttpClient getClient(HttpUriRequest request) {
>>  ClientConnectionManag