hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Keep alive questions
Date Fri, 18 Jun 2010 10:25:06 GMT
On Wed, 2010-06-16 at 17:55 +0200, Joan Balaguero wrote:
> Hello,
> 
>  
> 
> I have three questions abut keeupAlive:
> 
>  
> 
> 
> 
> 1.  If “getKeepAliveDuration” returns 0, that means:
>  
> a.  No keep alive 
> OR
> b.  Keep connections alive indefinitely. 
>  
> 

Neither. It means the connection will be placed in the pool and will
expire immediately.

> 
> 2.       If I want to remove the keep alive strategy, what should I do? Call
> “http.setKeepAliveStrategy(null)”?
> 

What do you mean by removing keep alive strategy? Not re-using
connections at all?

Anyways, you should implement a custom ConnectionKeepAliveStrategy if
you want to customize the keep-alive time of persistent connections. If
you so not want connections to be kept-alive at all (which is generally
not recommended) you should implement a custom
ConnectionReuseStrategy.  

>  
> 
> 3.       At this moment, I have an IdleConnectionHandler that is triggered
> every 30 seconds and does the following:
> 
>  
> 
>    this.cm.closeExpiredConnections();
> 
>    this.cm.closeIdleConnections(this.idleTimeout, TimeUnit.SECONDS);
> 
>  
> 
> But if I set a keep alive strategy, then it’s not necessary to call to
> “closeExpiredConnections”, is it?
> 

It is not necessary but recommended. Without #closeExpiredConnections an
expired connection will remain in the pool until a request for a
connection lease is made. You may really want to evict expired
connections from the pool on a more regular basis.  

Oleg


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Mime
View raw message