3

我使用 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 任务失败(如预期的那样)。

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

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

我想到了两种可能的解决方法:

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

我想解决问题,而不是解决问题。 你有什么建议吗?

线程仍然卡住,可以从中提取一些有用的信息吗?我只是用来kill -3 $PID获取线程转储。

4

2 回答 2

5

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

响应超时:等待响应的毫秒数。

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

  • http.connection.stalecheck

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

确定是否要使用陈旧连接检查。在服务器端关闭的连接上执行请求时,禁用陈旧连接检查可能会导致轻微的性能提升,但有可能出现 I/O 错误。

于 2013-04-30T19:56:22.527 回答
3

您可以在 Jmeter 属性文件中设置默认超时设置,见下文:(Jmeter 版本 2.6.11)

# Following properties apply to both Commons and Apache HttpClient

# set the socket timeout (or use the parameter http.socket.timeout)
# Value is in milliseconds
httpclient.timeout=60000
# 0 == no timeout
于 2014-01-16T06:09:56.737 回答