You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by mrbeagle <ji...@gmail.com> on 2010/09/05 23:56:03 UTC

What is the determining factor for Max Connections?

I have a server app that currently has 100 worker threads that fetch data
from links. Currently I have

ConnManagerParams.setMaxTotalConnections(httpParams, Integer.MAX_VALUE);

but I'm curious what I should be setting that to and I'm not sure I know
what factors go into deciding that number, ram? network bandwidth? cpu? 

Whats the rule of thumb for determining the optimal number for your app?

thanks
-- 
View this message in context: http://old.nabble.com/What-is-the-determining-factor-for-Max-Connections--tp29627879p29627879.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: What is the determining factor for Max Connections?

Posted by Ken Krugler <kk...@transpac.com>.
On Sep 5, 2010, at 2:56pm, mrbeagle wrote:

>
> I have a server app that currently has 100 worker threads that fetch  
> data
> from links. Currently I have
>
> ConnManagerParams.setMaxTotalConnections(httpParams,  
> Integer.MAX_VALUE);
>
> but I'm curious what I should be setting that to and I'm not sure I  
> know
> what factors go into deciding that number, ram? network bandwidth?  
> cpu?
>
> Whats the rule of thumb for determining the optimal number for your  
> app?

I don't know of any quantitative ways to set that number to an  
appropriate value.

For tuning this on some EC2 instances, I kept bumping it up until I  
started seeing reduced gain in throughput, coupled with high(er) load  
on the box.

External factors such as whether you've got a local caching DNS server  
can influence throughput as well (if you're doing a large-scale web  
crawl, at least) so this tuning needs to include the entire  
environment, not just HttpClient parameters.

-- Ken

--------------------------
Ken Krugler
+1 530-210-6378
http://bixolabs.com
e l a s t i c   w e b   m i n i n g






---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: What is the determining factor for Max Connections?

Posted by Mike Boyers <mb...@yahoo.com>.
I don't know of a concrete rule of thumb, but I'll share my thinking about how I've tuned my configuration.  I don't know if my way of thinking is common or not.

For me, the most important reason for having max-total-connections be something smaller than Integer.MAX_VALUE has to due more with the behavior when something is under duress as opposed to overall memory, cpu, etc.

If you have it set to "infinite" as you do currently, and one (or all) of the remote hosts your HttpClient is talking to becomes very slow in responding or unresponsive altogether, how many threads are you willing to have chewed up at any one given time by waiting for slow responses that may never come back with meaningful data?

I've worked with some folks who couldn't cache HttpClient responses (they were different every time), and who also were running at about 100 requests per second.  Their system would go down every time the main host they talked to through HttpClient went down because they had their max-total-connections set too high.

I'm from the school of thought where putting a hard limit on these types of expensive transactions is a very good thing.  If you're working on a system that's dependent on 10 other systems, the worst thing you can do is tune your system such that your entire system goes down every time any of those 10 systems goes down.

My suggestion is to determine what you think your true max is.  I feel that the ultimate way to do this is to instrument your production system to tell you what maximum it actually reaches and monitor it under real load and go from there.  If you're unable to do that, you can calculate it.  This depends on a lot of things only you will know depending on whether or not you're caching the HttpClient responses, how long they are cached, how many requests-per-second you need to do, etc.

In my case, and this might sound funny at first, my I also have my connection manager set the same way you do: ConnManagerParams.setMaxTotalConnections(httpParams, Integer.MAX_VALUE);

But this is because I have host-specific tunings for each HTTP host I talk to.  So while the "global" value is infinite, I have a max-connections for every different host that effectively sets the max-total-connections to the sum of all of my host-specific max-connections values.  I like this level of granularity because, in my case, some of the HTTP resources I talk to the least often are also the most fragile, and I can limit their impact on my system when they get sick without effecting the bulk of off-host HTTP traffic I generate.

Hope this helps,
Mike

--- On Sun, 9/5/10, mrbeagle <ji...@gmail.com> wrote:

> From: mrbeagle <ji...@gmail.com>
> Subject: What is the determining factor for Max Connections?
> To: httpclient-users@hc.apache.org
> Date: Sunday, September 5, 2010, 5:56 PM
> 
> I have a server app that currently has 100 worker threads
> that fetch data
> from links. Currently I have
> 
> ConnManagerParams.setMaxTotalConnections(httpParams,
> Integer.MAX_VALUE);
> 
> but I'm curious what I should be setting that to and I'm
> not sure I know
> what factors go into deciding that number, ram? network
> bandwidth? cpu? 
> 
> Whats the rule of thumb for determining the optimal number
> for your app?
> 
> thanks
> -- 
> View this message in context: http://old.nabble.com/What-is-the-determining-factor-for-Max-Connections--tp29627879p29627879.html
> Sent from the HttpClient-User mailing list archive at
> Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 
> 


      

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org