编程语言
首页 > 编程语言> > java-使用JMeter与1000位用户进行负载测试时,Apache Tomcat Connection Refused错误

java-使用JMeter与1000位用户进行负载测试时,Apache Tomcat Connection Refused错误

作者:互联网

我已经在Linux和Apache Tomcat 7.0.42中部署了Java EE应用程序

当我使用JMeter对100个用户进行负载测试时,一切正常(并发100个线程请求)

但是,一旦我将用户(或线程数)更改为1000,服务器就会被阻塞,并且在〜600之后,所有请求都会出现“ Connection拒绝”错误.

我已经在应用程序中进行了所有的微调,它现在更多的是静态网页,即使这样它也会返回错误.

服务器配置:Ubuntu,8 vCPU / 32 GB RAM / 960 GB HD

PS:相同的应用程序在AWS(Amazon Web Services)中运行良好,因此您可以排除运行JMeter(client)的我的机器出现任何问题

    org.apache.http.conn.HttpHostConnectException: Connection to http://a.b.c.d: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.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:645)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:480)
    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.sample(HTTPHC4Impl.java:286)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:62)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1088)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1077)
    at org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:428)
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.net.ConnectException: Connection timed out: connect
    at java.net.DualStackPlainSocketImpl.waitForConnect(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)
    ... 12 more

解决方法:

尝试调整server.xml中http连接器的maxThreads和acceptCount属性:

Each incoming request requires a thread for the duration of that
request. If more simultaneous requests are received than can be
handled by the currently available request processing threads,
additional threads will be created up to the configured maximum (the
value of the maxThreads attribute). If still more simultaneous
requests are received, they are stacked up inside the server socket
created by the Connector, up to the configured maximum (the value of
the acceptCount attribute). Any further simultaneous requests will
receive “connection refused” errors, until resources are available to
process them.

参考:http://tomcat.apache.org/tomcat-7.0-doc/config/http.html

标签:amazon-web-services,jmeter,apache,tomcat,java
来源: https://codeday.me/bug/20191122/2062667.html