3

When using the Apache PoolingClientConnectionManager such as:

PoolingClientConnectionManager cm = new PoolingClientConnectionManager();
cm.setMaxTotal(???);
HttpClient client = new DefaultHttpClient(cm);

What is considered a good default value to place there? An example on the Apache site here uses 100 and elsewhere (stackoverflow.com/questions/13310490/apache-defaulthttpclient-how-to-set-max-total-connection-and-default-max-conn) I read that one should know roughly what the peak load will be and set it to that.

So is there a good default value to place in setMaxTotal(???)? Or is it recommended to figure our what your peak is and base it off that?

If the latter, what's a good way of determining what your peak load is? I looked here through this slideshow and saw that the default is 10, though you can set it to 0 and just let the good times roll (although that apparently negates any time out services, any good reasons for that?). I also happened to glance through the oracle docs (docs.oracle.com/cd/E17904_01/web.1111/e13737/ds_tuning.htm) and saw some good tips on maintaining Connection Pools but nothing on determining the peak load.

Any help on this would be much appreciated.

Colin 't Hart
  • 7,372
  • 3
  • 28
  • 51

1 Answers1

0

Its always recommended to figure out your peak load is and set the value accordingly.

I also came across such a situation earlier. Dint find a proper way to get a good value for setMaxTotal().

But it worked out for me like this

You can do an lsof -p <process id> if your application is running on linux .

This will get you all the open connections from the application . And you can grep your target server name during heavy load.

lsof -p <process id>|grep <target server>

This will display all the connections to the target server from your application .

If httpclient will not cater heavy load , its always good to keep this value under 100. Pool will hold a maximum of only 100 objects.

Bijesh CHandran
  • 477
  • 1
  • 8
  • 22
  • 1
    I'm not running linux at the moment, so for anyone else who comes here and is also running windows, those commands do have windows equivalents - you can see [more here](http://stackoverflow.com/questions/15708/how-can-i-determine-whether-a-specific-file-is-open-in-windows) – user2577182 Aug 14 '13 at 16:33