hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Performance of stale connection check
Date Wed, 21 Feb 2007 22:35:44 GMT
On Wed, 2007-02-21 at 17:13 -0500, andrew.adamov@thomson.com wrote:
> Hi!
>  
> Are there any plans to improve performance of the stale connection
> check?  
>  
> Unfortunately, we can not currently migrate to HttpClient because we
> can't afford 15-30 ms for stale checks in our environment where complete
> HTTP requests take 10 ms.  We do need the robustness provided by stale
> checks so disabling them is not a good option for us.
>  
> One way to implement fast stale checks is to use non-blocking reads with
> channels:
>  
>         try {
>             channel.configureBlocking( false );            
>             count = channel.read( buffer );
>             // connection closed if count == -1 (log EOF)
>         }
>         catch( Exception e ) {            
>             // connection reset (log exception)
>         }
>         finally {
>             channel.configureBlocking( true );
>         }
>  
> This code successfully detects closed and aborted/reset connections, and
> runs in < 1 ms.
>  
> Thanks.
>  
> - Andrew
>  

Andrew,

Unfortunately we cannot use NIO in HttpClient 3.x because of the Java
1.2.2 compatibility requirement. The stale connection check will always
remain slow due to the inherent limitations of the blocking I/O in Java
(in many JRE implementations the effective socket timeout granularity is
15 - 30ms). There is not much we can do about it.

Oleg




---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org


Mime
View raw message