HttpClient大并发下Timeout waiting for connection from pool优化方案

(本文的优化方案是由同事给出,我就对此做一下整理,记录分享给大家)


当前用的httpclient  jar 包是 httpclient-4.3.6,相对应之前的版本是有一些不同的,用起来也会出现一些问题,但是可以通过配置参数解决我遇到的问题

HttpClient一些正常所需的参数:

//设置连接超时时间

private static int socketTimeout = 2000;
private static int connectTimeout = 2000;
private static int connectionRequestTimeout = 10000;

在做性能测试时,tps=50时,绝大部分的请求都是正常的,只有少数请求抛出了如下异常:

2015-12-23 11:50:45.716 INFO  [[ACTIVE] ExecuteThread: '21' for queue: 'weblogic.kernel.Default (self-tuning)'] AssetCrowdFundQueryServiceImpl line35 - AssetCrowdFundQueryServiceImpl queryCrowdFunding is SUCCESS, Exception{}
java.io.IOException: org.apache.http.conn.ConnectionPoolTimeoutException: <span style="color:#ff0000;">Timeout waiting for connection from pool</span>
         at com.pingan.toa.asset.common.utils.http.HttpClientUtil.post(HttpClientUtil.java:180) ~[asset-common-1.0.0-SNAPSHOT.jar:na]
         at com.pingan.toa.asset.common.utils.http.HttpClientUtil.post(HttpClientUtil.java:158) ~[asset-common-1.0.0-SNAPSHOT.jar:na]
         at com.pingan.toa.asset.service.crowdfunding.impl.AssetCrowdFundQueryServiceImpl.queryCrowdFunding(AssetCrowdFundQueryServiceImpl.java:32) ~[asset-service-1.0.0-SNAPSHOT.jar:na]
         at com.pingan.toa.asset.facade.crowdfunding.impl.CrowdFundingAssetFacadeImpl.getCrowdFundInfo(CrowdFundingAssetFacadeImpl.java:173) ~[asset-facade-1.0.0-SNAPSHOT.jar:na]
         at sun.reflect.GeneratedMethodAccessor145.invoke(Unknown Source) ~[na:na]
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[na:1.6.0_37]
         at java.lang.reflect.Method.invoke(Method.java:597) ~[na:1.6.0_37]
         at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:188) ~[cxf-api-2.7.17.jar:2.7.17]
         at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:104) ~[cxf-api-2.7.17.jar:2.7.17]
         at org.apache.cxf.jaxrs.JAXRSInvoker.inv
  • 4
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值