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.

 

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?

 

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?
Then, in cases like these MaxConnectionsPerRoute becomes the limiting
value for the number of allowed connections rather than the
MaxTotalConnections. Is this observation correct? 

 

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

 

Please help in understanding/ validating this assumption.

 

Thanks,

Brijesh

Reply via email to