jmeter测试网站性能connection refused timeout

ustcshopping
  • 67

我用Jmeter2.13测试网站一个http请求,服务器是tomcat7,测试500个线程数正常,增加到750就会出现connection refused错误,而且一般是最后的请求出现错误,前面仍是对的。试了网上一些方法增加tomcat7 server.xml最大线程数,修改系统参数等都不行。此时CPU内存带宽IO都是没有满的,所以不知瓶颈在何处??希望有遇到过类似情况或者知道的人能解答,谢谢!
结果树中错误代码如下:

org.apache.http.conn.HttpHostConnectException: Connection to http://10.0.0.160:8080 refused

at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:190)
at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:294)
at org.apache.jmeter.protocol.http.sampler.MeasuringConnectionManager$MeasuredConnection.open(MeasuringConnectionManager.java:107)
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:643)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:479)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.executeRequest(HTTPHC4Impl.java:517)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:331)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:74)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1146)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1135)
at org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:434)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:261)
at java.lang.Thread.run(Unknown Source)

Caused by: java.net.ConnectException: Connection timed out: connect

at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:127)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:180)
... 14 more
评论
阅读 14.8k
3 个回答

我之前也遇到过一次情况,可能是因为端口号耗尽,一般一台服务器的端口号最多是65535个,建议使用该命令分别查看下压测机与服务器的端口使用情况,netstat -nat|grep -i 8080|wc -l,如果这个个数在6w左右,那可能就是端口号用尽,同时查看下大多数的端口状态,应该都是time_wait状态
解决方案:
如果是压测机,端口号用尽,那就增加压测机,使用jmeter分布式压测(jmeter默认开启keep_alive的)
如果数服务器,端口号用尽,最大的可能是服务器端开了短链接,把短链接配置变成长连接即可
因为如果服务器端是短链接,当jmeter每发起一个请求就会建立一次tcp三次握手,传输完数据后,连接其实没有关,连接状态是time_wait,下个请求来了,会重新开启一个新的端口,建立tcp三次握手,传输数据....,这样随着请求的越来越多,端口就会变得越来越少,所以端口很快耗尽,而且大多数端口都处于time_wait状态,如果服务器端也支持长连接,那么下次请求来了,就会在上次请求的通道上继续传输,端口使用率大大的降低,就有效的避免了端口耗尽问题

我也碰到这个问题了……请高手出马解释解释,为我等解惑:(

蔡志超
  • 3
新手上路,请多包涵

it女神* 说得对

撰写回答

登录后参与交流、获取后续更新提醒

宣传栏