[
https://issues.apache.org/jira/browse/HTTPCLIENT-1334?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Oleg Kalnichevski resolved HTTPCLIENT-1334.
-------------------------------------------
Resolution: Not A Problem
Use whatever approach that you deem the most appropriate for your particular
application.
In my experience a pool of connections always tends to perform better than the
same number of non-pooled connections despite the overhead of thread contention
for the pool lock. 200 requests are simply non-representative. Try running your
test with 200'000 requests at _least_ and see what happens.
Oleg
PS: You might want to try using a separate HttpClient instance per thread
sharing the same connection manager to eliminate thread contention on
HttpClient instance.
PPS: Please do not re-open the issue. If you have any follow-up questions
please post them to the user list.
> 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
> Attachments: Wire_log.txt
>
>
>
> 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]