hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Boyers <mboy...@yahoo.com>
Subject Re: What is the determining factor for Max Connections?
Date Mon, 06 Sep 2010 16:13:09 GMT
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,

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

> From: mrbeagle <jiminoc@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

View raw message