使用 JMeter 对 1000 个用户进行负载测试时出现 Apache Tomcat 连接被拒绝错误 [英] Apache Tomcat Connection Refused error while load testing with 1000 users using JMeter
问题描述
我已经在 linux 和 Apache Tomcat 7.0.42 中部署了一个 Java EE 应用程序
I have deployed a Java EE application in linux and Apache Tomcat 7.0.42
当我使用 JMeter 对 100 个用户进行负载测试时,一切正常(并发 100 个线程请求)
Everything works fine when I load test for 100 users using JMeter(concurrent 100 threads requests)
但是一旦我将用户(或线程数)更改为 1000,服务器就会被阻塞,并且在 ~600 之后的所有请求都会出现连接被拒绝"错误.
But as soon as I change the users(or number of threads) to 1000 server is choked and it gives "Connection refused" error for all the requests after ~600.
我已经在应用程序中进行了所有微调,现在它更像是一个静态网页,即便如此,它也会出现错误.
I have done all fine tuning in the application and it is more of of a static web page now, even then it comes back with error.
服务器配置:Ubuntu,8 vCPU/32 GB RAM/960 GB HD
Server Configuration: Ubuntu, 8 vCPU / 32 GB RAM / 960 GB HD
PS:同样的应用程序在 AWS(亚马逊网络服务)中运行良好,所以你可以排除我的机器运行 JMeter(客户端)的任何问题
PS: The same application works well in AWS(Amazon Web Services), so you can rule out any problem with my machine running 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
属性/代码>:
Try adjusting the maxThreads
and acceptCount
attributes of the http connector in server.xml
:
每个传入请求在此期间都需要一个线程要求.如果同时收到的请求多于可以由当前可用的请求处理线程处理,额外的线程将被创建到配置的最大值(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
这篇关于使用 JMeter 对 1000 个用户进行负载测试时出现 Apache Tomcat 连接被拒绝错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!