gpt4 book ai didi

java - JMeter HTTP 请求挂起(可能是在重载网络上)

转载 作者:可可西里 更新时间:2023-11-01 16:04:43 27 4
gpt4 key购买 nike

我使用 JMeter 测试来检查我们的应用程序是否正在运行。这些测试是从 Jenkins 通过 ANT <jmeter> 运行的标签。问题是,JMeter 有时会永远挂起(并且 Jenkins 执行程序因仍在运行而被阻止)。在两个月内(每 10 分钟运行一次测试)只发生了两次这样的挂起,但是今天,两个并行测试同时卡住了(5 分钟内,不同的测试)。我确实怀疑网络连接(它经常过载且不可靠),但我希望即使在这样的环境中测试也能可靠。

卡住进程的线程转储是:

   [jmeter] "User test 1-1" prio=10 tid=0x00007fd56c43f000 nid=0x2797 runnable [0x00007fd5704e2000]
[jmeter] java.lang.Thread.State: RUNNABLE
[jmeter] at java.net.SocketInputStream.socketRead0(Native Method)
[jmeter] at java.net.SocketInputStream.read(SocketInputStream.java:146)
[jmeter] at org.apache.http.impl.io.AbstractSessionInputBuffer.read(AbstractSessionInputBuffer.java:204)
[jmeter] at org.apache.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:177)
[jmeter] at org.apache.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:201)
[jmeter] at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:155)
[jmeter] at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.readResponse(HTTPSamplerBase.java:1649)
[jmeter] at org.apache.jmeter.protocol.http.sampler.HTTPAbstractImpl.readResponse(HTTPAbstractImpl.java:235)
[jmeter] at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:300)
[jmeter] at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:62)
[jmeter] at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.followRedirects(HTTPSamplerBase.java:1410)
[jmeter] at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.resultProcessing(HTTPSamplerBase.java:1481)
[jmeter] at org.apache.jmeter.protocol.http.sampler.HTTPAbstractImpl.resultProcessing(HTTPAbstractImpl.java:251)
[jmeter] at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:358)
[jmeter] at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:62)
[jmeter] at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1088)
[jmeter] at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1077)
[jmeter] at org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:428)
[jmeter] at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256)
[jmeter] at java.lang.Thread.run(Thread.java:679)

从第二个测试(这个测试 www.google.com 的可达性):

   [jmeter] "www.google.com 1-1" prio=10 tid=0x0000000000d32000 nid=0x27e8 runnable [0x00007fb9fea54000]
[jmeter] java.lang.Thread.State: RUNNABLE
[jmeter] at java.net.SocketInputStream.socketRead0(Native Method)
[jmeter] at java.net.SocketInputStream.read(SocketInputStream.java:146)
[jmeter] at org.apache.http.impl.io.AbstractSessionInputBuffer.read(AbstractSessionInputBuffer.java:204)
[jmeter] at org.apache.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:177)
[jmeter] at org.apache.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:201)
[jmeter] at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:155)
[jmeter] at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.readResponse(HTTPSamplerBase.java:1649)
[jmeter] at org.apache.jmeter.protocol.http.sampler.HTTPAbstractImpl.readResponse(HTTPAbstractImpl.java:235)
[jmeter] at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:300)
[jmeter] at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:62)
[jmeter] at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1088)
[jmeter] at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1077)
[jmeter] at org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:428)
[jmeter] at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256)
[jmeter] at java.lang.Thread.run(Thread.java:679)

我使用 HTTP Request具有默认值的采样器:

    <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="www.google.cz" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="HTTPSampler.domain">www.google.cz</stringProp>
<stringProp name="HTTPSampler.port"></stringProp>
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
<stringProp name="HTTPSampler.response_timeout"></stringProp>
<stringProp name="HTTPSampler.protocol">http</stringProp>
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
<stringProp name="HTTPSampler.path"></stringProp>
<stringProp name="HTTPSampler.method">GET</stringProp>
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
<boolProp name="HTTPSampler.monitor">false</boolProp>
<stringProp name="HTTPSampler.embedded_url_re"></stringProp>
</HTTPSamplerProxy>

未设置超时,但我尝试默认超时为 240 秒 - 当我尝试 GET从无响应站点,一切正常,240 秒后 JMeter 任务失败(如预期)。

在 linux 机器上运行的 JMeter 版本是 2.9。

当我向系统管理员询问网络时,他说它可能重载了。我无法重现该错误,因为它发生得太少了(我也没有 TCP 转储)。

我考虑了两种可能的解决方法:

  • 向 JMeter 添加超时以终止有问题的线程 - 我不确定如何,有什么提示吗?
  • 为 Jenkins 添加超时 - 使用 Build-timout plugin

但是我想解决问题,而不是制定解决方法。你有什么建议吗?

线程还是卡住了,能否从中提取一些有用的信息?我刚用过 kill -3 $PID获取线程转储。

最佳答案

为什么不直接向 HTTP 采样器添加响应超时:

Response Timeout : Number of milliseconds to wait for a response.

如果你使用HTTPClient4,那么你可能会有以下选项,将它添加到httpclient.parameters:

  • http.connection.stalecheck

参见 http://hc.apache.org/httpclient-legacy/preference-api.html#HTTP_connection_parameters :

Determines whether stale connection check is to be used. Disabling stale connection check may result in slight performance improvement at the risk of getting an I/O error when executing a request over a connection that has been closed at the server side.

关于java - JMeter HTTP 请求挂起(可能是在重载网络上),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16286500/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com