简体   繁体   English

JMeter的线程(用户)参数增加时连接被拒绝错误

[英]Connection refused error when number of threads(users) parameter of JMeter increased

Iam trying to do a performance test against my application via JMeter.我正在尝试通过 JMeter 对我的应用程序进行性能测试。 When i increase the number of threads(users) more than 100 i'm getting these errors.当我将线程(用户)的数量增加到 100 以上时,我会收到这些错误。 Please help me to fix this.请帮我解决这个问题。

NB: This was working fine until i increased the no: of threads to 25000.
    Docker container is up and accepting connections(working fine with Postman)
[enter image description here][1]
[enter image description here][2]
[enter image description here][3]

org.apache.http.conn.HttpHostConnectException: Connect to 127.0.0.1:8080 [/127.0.0.1] failed: Connection refused (Connection refused)
    at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:156)
    at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl$JMeterDefaultHttpClientConnectionOperator.connect(HTTPHC4Impl.java:404)
    at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:376)
    at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:393)
    at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
    at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
    at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
    at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
    at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
    at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.executeRequest(HTTPHC4Impl.java:935)
    at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:646)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:66)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1296)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1285)
    at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:638)
    at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:558)
    at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:489)
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.ConnectException: Connection refused (Connection refused)
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:607)
    at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:75)
    at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
    ... 19 more


  [1]: https://i.stack.imgur.com/Z6b1h.png
  [2]: https://i.stack.imgur.com/JDWYa.png
  [3]: https://i.stack.imgur.com/4Qtrx.png

I don't think your "performance test" makes a lot of sense because:我认为您的“性能测试”没有多大意义,因为:

  1. You're running JMeter and the system under test on the same machine, both can be very resource intensive and results won't be reliable due to race conditions您在同一台机器上运行 JMeter 和被测系统,两者都可能非常耗费资源,并且由于竞争条件,结果将不可靠
  2. You're running your test in GUI mode, it's for tests development and debugging, when it comes to tests execution you should be running your JMeter tests in command-line non-GUI mode您在 GUI 模式下运行测试,它用于测试开发和调试,当涉及到测试执行时,您应该在命令行非 GUI 模式下运行 JMeter 测试
  3. You're running your tests on a laptop which is not connected to power supply so the power saving mode most likely will cause CPU to throttle您在未连接电源的笔记本电脑上运行测试,因此省电模式很可能会导致 CPU 节流
  4. You have a lot of Listeners enabled which don't add any value and just consume resources启用了许多侦听器,它们不会增加任何价值,只会消耗资源

Coming back to your question I can think of 2 possible reasons:回到你的问题,我可以想到两个可能的原因:

  1. You've exceeded the maximum number of open connections on the target webserver, check your backend HTTP server documentation to determine how to increase the number of open connections您已超过目标 Web 服务器上的最大打开连接数,请检查您的后端 HTTP 服务器文档以确定如何增加打开连接数
  2. You've exceeded the maximum number of open connections on your operating system level, check the current limits and amend according to your test scenario.您已超出操作系统级别的最大打开连接数,请检查当前限制并根据您的测试场景进行修改。

It seems like you're basically running a DoS attack against your own server.看起来您基本上是在对自己的服务器进行 DoS 攻击。

  1. Check your server configuration for concurrency (eg Tomcat has a 'maxThreads'. Apache might have MPM enabled)检查您的服务器配置的并发性(例如,Tomcat 有一个“maxThreads”。Apache 可能启用了 MPM)
  2. Check if your JMeter test produces reasonable load.检查您的 JMeter 测试是否产生合理的负载。 Does 1 thread represent 1 user? 1 个线程是否代表 1 个用户? If so, do those users pause between requests?如果是这样,这些用户会在请求之间暂停吗? (Use a random wait in JMeter) (在 JMeter 中使用随机等待)

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

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