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: MaxTotalConnections and MaxConnectionPerRoute in case of httpclient instance per target host
Date Mon, 17 Aug 2009 09:37:42 GMT
On Mon, Aug 17, 2009 at 12:37:37AM +0530, Brijesh Deo wrote:
> Hi,
> 
>  
> 
> I am implementing an http reverse proxy, somewhat on the lines of the
> sample implementation - ElementalReverseProxy with some modifications. I
> am using HttpCore classes to implement the http server (using
> org.apache.http.protocol.HttpService) and the HttpClient api (instead of
> the HttpRequestExecutor) to implement the client side for sending the
> Http requests to the target servers and receiving Http Responses from
> them. I am using the latest HttpClient 4.0 binaries bundle (with
> dependencies).
> 
>  
> 
> I need to provide access to several backend http web-servers through my
> reverse proxy. For that, I am creating one HttpClient instance per
> backend host and all requests targeted to a particular target host are
> executed using the corresponding httpClient instance. Every httpClient
> instance uses separate instances of ThreadSafeClientConnManager. Every
> HttpClient-ThreadSafeClientConnManager pair has MaxTotalConnections = 20
> and MaxConnectionsPerRoute = 10.
> 
> 

I personally see no benefit of having multiple HttpClient / ConnectionManager,
(a pair per target host). A single HttpClient instance with
ThreadSafeClientConnManager would do the job just as well.

 
> 
> With respect to this I have the following questions:
> 
>  
> 
> 1) Since I have one HttpClient-ThreadSafeClientConnManager instances
> pair for one target host, can there be multiple routes (HttpRoute) to
> the same target server while executing requests from the HttpClient? Or
> would there be only one route to a given target host in this case?
> 
> 

Only one route, provide you do not use different proxies to access the same
target host.

 
> 
> 2) I have noticed that when multiple threads are executing requests to a
> given target server using the corresponding HttpClient instance, I get
> ConnectionPoolTimeoutException at times when the no of connections
> touches MaxConnectionsPerRoute (10) even though the MaxTotalConnections
> is 20. So, do all the connections use the same route in such scenarios?

Apparently, they do

> Then, in cases like these MaxConnectionsPerRoute becomes the limiting
> value for the number of allowed connections rather than the
> MaxTotalConnections. Is this observation correct? 
> 
>  

Yes, it is


> 
> 3) In cases like this, do the two parameters MaxTotalConnections and
> MaxConnectionPerRoute need to have the same value?
> 
>  

No, they do not, but the exact setup depends on particular needs of your
applications.

For instance one many want to ensure that there is no more than 10 connections
to Host A and no more than 10 connections to Host B, but simultameously there
is no more than 15 connections in total at the same time.

Oleg

> 
> Please help in understanding/ validating this assumption.
> 
>  
> 
> Thanks,
> 
> Brijesh
> 

---------------------------------------------------------------------
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