简体   繁体   English

Apache Tomcat连接使用JMeter对1000个用户进行负载测试时拒绝错误

[英]Apache Tomcat Connection Refused error while load testing with 1000 users using JMeter

I have deployed a Java EE application in linux and Apache Tomcat 7.0.42 我在linux和Apache Tomcat 7.0.42中部署了一个Java EE应用程序

Everything works fine when I load test for 100 users using JMeter(concurrent 100 threads requests) 当我使用JMeter为100个用户加载测试时,一切正常(并发100个线程请求)

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. 但是一旦我将用户(或线程数)更改为1000服务器就会被阻塞,并且在~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. 我已经完成了应用程序中的所有微调,现在它更像是一个静态网页,即使这样它又会出现错误。

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

PS: The same application works well in AWS(Amazon Web Services), so you can rule out any problem with my machine running JMeter(client) PS:相同的应用程序在AWS(亚马逊网络服务)中运行良好,因此您可以排除运行JMeter(客户端)的计算机的任何问题

    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

Try adjusting the maxThreads and acceptCount attributes of the http connector in server.xml : 尝试调整server.xml http连接器的maxThreadsacceptCount属性:

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). 如果收到的并发请求多于当前可用的请求处理线程可以处理的请求,则将创建其他线程,直到达到配置的最大值( maxThreads属性的值)。 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). 如果收到更多并发请求,它们将堆叠在连接器创建的服务器套接字内,最多为配置的最大值( acceptCount属性的值)。 Any further simultaneous requests will receive "connection refused" errors, until resources are available to process them. 任何进一步的同时请求将收到“连接被拒绝”错误,直到资源可用于处理它们。

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

Thank you all!! 谢谢你们!!

Problem was actually with network, when we tested using different IP address(IP spoofing), all requests were successful. 问题实际上是网络,当我们使用不同的IP地址(IP欺骗)进行测试时,所有请求都是成功的。 Network was thinking that it was a DoS attack. 网络认为这是一次DoS攻击。

Thanks all. 谢谢大家。 I had tried maxThreads & acceptCount and did a lot of tuning in Linux. 我曾尝试过maxThreads和acceptCount,并在Linux中做了很多调整。

So the learning is: Conduct the performance test from a server which is located in the same zone. 因此,学习是:从位于同一区域的服务器进行性能测试。

Possibly 1000 concurrent requests (in one second) is out of reality. 可能1000个并发请求(在一秒内)不可实现。 A better test would be to distribute the 1000 concurrent requests in an interval of time. 更好的测试是在一段时间内分配1000个并发请求。

eg: The image show that 100 requests are executed in a period of 60 seconds, ie, almost two requests per second. 例如:图像显示在60秒的时间段内执行100个请求,即每秒几乎两个请求。

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM