On Thu, 2008-04-03 at 22:22 -0700, Sujith Joseph wrote:
> 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.
> 

Sujith,

SimpleHttpConnectionManager holds only one connection object. There is
no benefit in pooling SCM instances. You can as well maintain a pool of
HTTP connections. 

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

HttpClient 4.x API is much, much more modular and flexible. You'll need
to write a lot less custom code. 


>  I am also thinking of
> a custom implementation of the HttpConnectionManager for this. Please
> advise.
> 

I do not see a way around writing a custom connection manager, which is
not an easy task.

Oleg

> 
> Thanks,
> Sujith


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to