[
https://issues.apache.org/jira/browse/HTTPCLIENT-1334?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
thomas reopened HTTPCLIENT-1334:
--------------------------------
Thanks oleg ,
I have used the client program from
https://svn.apache.org/repos/asf/httpcomponents/benchmark/httpclient/trunk/src/main/java/org/apache/http/client/benchmark/
I tested with 200 requests with 5 worker threads and 5 concurrent requests as
suggested by you . In this case , the httpclient with connection manager
perform better . But when I raised the bar to 200 requests , 50 worker threads
and 50 concurrent requests , the performance become slower than that of the
no pooling version of the code.Is it the case like the 50 concurrent requests
try to acquire lock simultaneously make the connection manager slow ? . My
application need to service atleast 100 concurrent requests , in this case
would it be better to go for the no pooling version of the code (create
individual httpclient instances for each requests).
> PoolingClientConnectionManager Performance issue
> ------------------------------------------------
>
> Key: HTTPCLIENT-1334
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1334
> Project: HttpComponents HttpClient
> Issue Type: Test
> Components: HttpConn
> Affects Versions: 4.2.2
> Environment: mac osx
> Reporter: thomas
> Labels: performance
>
>
> I have the following code which use a PoolingClientConnectionManager:
> public static void main(String[] args) {
> int NoOfSimultaneousRequest = 1000;
> int poolsize =1000;
> try{
> if (poolsize>0){
> mgr = new PoolingClientConnectionManager();
> mgr.setMaxTotal(poolsize);
> mgr.setDefaultMaxPerRoute(poolsize);
> httpclient = new DefaultHttpClient(mgr);
> }
> Thread [] tr = new Thread[NoOfSimultaneousRequest];
> for(int i=0;i<NoOfSimultaneousRequest;i++){
> MultipleThreadsTest multiTest = new MultipleThreadsTest();
> Thread t = new Thread(multiTest);
> tr[i] = new Thread(multiTest);
> }
> for(int i=0;i<NoOfSimultaneousRequest;i++){
> tr[i].start();
> }
> for(int i=0;i<NoOfSimultaneousRequest;i++){
> tr[i].join();
> }
> }catch (Exception e){
> e.printStackTrace();
> }finally{
> if (mgr!=null){
> mgr.shutdown();
> }
> if (httpclient!=null){
> httpclient.getConnectionManager().shutdown();
> }
> }
> }
> public void run() {
> if (mgr==null){ //if no connection manager then create multiple
> instances of defaulthttpClient
> HttpClient hc = new DefaultHttpClient();
> response = invokeWebService(hc,"http://urltoPost") ;
> }else{ //if connection manager is used then use only one instance
> of httpclient
> response = invokeWebService(httpclient,"http://urltoPost") ;
> }
> }
> private static String invokeWebService(HttpClient httpClient,String url){
> HttpPost httpPost = new HttpPost(new URI(url));
> try{
> String response = httpClient.execute(httpPost,new
> BasicResponseHandler());
> return response;
> }catch(Exception e){
> }finally{
> if (httpPost != null) {
> httpPost.releaseConnection();
> }
> }
> }
> My problem is , when I turn off pooling (by setting poolSize<=0) the code
> performs much faster compared to pooling on (poolSize>0) .The only difference
> between these two versions is , when using pooling , there is only one
> instance of httpClient created (Apache recomended) and when pooling off ,
> multiple instances of httpclient is created .The code is supposed to perform
> better when I use http conection pooling . But that is not happening . Do you
> see any issue in the usage of connection manager?
> Thanks & Regards Thomas
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]