Hi,
   I am trying to implement a way of throttling http connections to a web
server from a web service, using httpclient, so that the web server wouldn't
be overloaded with more than 'x' concurrent connections, from my web
service. (I also need to ensure that the http connections available in the
pool are utilized efficiently).

Within the web service, the http connections are created for various types
of (client) applications and each such application has a preferred limit on
the number of concurrent connections, it can create to the server. However
if the connections requested by a particular application gets higher than
its preferred limit, it could consume free http connections allocated to
other applications. The thus eagerly acquired connections must be released,
if the rest of the applications requests back for their allotted
connections.


To implement this, I am thinking of using a custom object pool of
SimpleHttpConnectionManager objects for each of the applications and have a
logic to maintain and regulate the number of these objects allocated/used,
based on the load, during new connection requests. For each web server
request, the plan is to create a connection from the
SimpleHttpConnectionManager using a HttpClient and release it, after getting
a response.

Can someone help me with a better solution for this? I know that the
MultiTHreadedConnectionManager keeps a pool of connections, but I am not
sure, whether we can dynamically manipulate the max connections to a host,
after an MTCM object creation (My understanding on MTCM is that it creates
as many threads as the max connection limit on its creation). Is there
something in Httpclient4.x that might help me in this? I am also thinking of
a custom implementation of the HttpConnectionManager for this. Please
advise.


Thanks,
Sujith

Reply via email to