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 "Christianson, Ryan" <Ry...@disney.com> on 2008/02/23 01:14:53 UTC

configuration suggestions for doing 100's of connections per second?

I have a product which post many requests to a http server. We are
trying to tune this to handle as many transactions per second as
possible. I think we've landed at the best configuration, but I wanted
to get feedback on this to see if there is a better configuration.
Basically I am setting up a HttpClient using a
MultiThreadedHttpConnectionManager. Next I create PostMethod objects,
call execute in a try/finally. In the finally I call
post.releaseConnection().

Also, on the side anyone else trying to use the
MultiThreadedHttpConnectionManager should note that the default max
threads per host is 2. This means if you are posting the same site over
and over again, you will only have 2 threads available to you.

One area that I am unsure of is if this implementation allows for
connection reuse. I've read other posts that talk about needing to
"consume the entire response" to enable connection reuse. 

With the setup below we are able handle about 250 transactions per
second.

Lastly, I noticed that there is work going on for NIO based HttpClients-
any idea when that will be out of beta?

Thanks for your thoughts!

-- setup HttpClient ------------------------------------------
MultiThreadedHttpConnectionManager connectionManager = new
MultiThreadedHttpConnectionManager();

connectionManager.getParams()
		.setMaxTotalConnections(50); // 50 is actually
configured somewhere else
connectionManager.getParams().setTcpNoDelay(true);
connectionManager
		.getParams()
		.setDefaultMaxConnectionsPerHost(50); // 50 is actually
configured somewhere else

mClient = new HttpClient(connectionManager);
-- end setup HttpClient ------------------------------------------


-- post method ------------------------------------------
PostMethod post = new PostMethod(url);
post.getParams().setSoTimeout(timeout);

try {
	mClient.executeMethod(post);
	String results = post.getResponseBodyAsString();
	return results;
}
finally {
	post.releaseConnection();
}
-- end post method ------------------------------------------



Ryan Christianson ~ Ryan.Christianson@disney.com
Walt Disney Internet Group | Staff Engineer, Mobile Engineering
925 4th Avenue, Suite 1600, Seattle, WA 98104 | mailcode: 9051
office: 206-664-4263 | tie: 8664-4263


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


Re: configuration suggestions for doing 100's of connections per second?

Posted by Roland Weber <os...@dubioso.net>.
Hi Ryan,

> Basically I am setting up a HttpClient using a
> MultiThreadedHttpConnectionManager. Next I create PostMethod objects,
> call execute in a try/finally. In the finally I call
> post.releaseConnection().
> 
> One area that I am unsure of is if this implementation allows for
> connection reuse. I've read other posts that talk about needing to
> "consume the entire response" to enable connection reuse. 

Yes it does allow for reuse. The entire response is consumed
automatically when you call post.releaseConnection(), if the
headers sent and returned allow for connection reuse.

cheers,
   Roland


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