为什么通过验证日志与服务器时间相比,Jmeter 响应时间不准确

Why Jmeter response time is not accurate when compared it with server time by verifying logs

我的查询是当我完成性能测试并获得结果文件时,我可以看到 Jmeter 响应时间和服务器响应时间之间存在差异。 我通过检查服务器 logs.I 来验证服务器响应时间,我也没有在结果文件中写入任何额外的元素。 我能解释一下为什么 Jmeter 显示的响应时间总是比实际响应时间高

你考虑过网络吗?根据JMeter glossary:

Elapsed time. JMeter measures the elapsed time from just before sending the request to just after the last response has been received. JMeter does not include the time needed to render the response, nor does JMeter process any client code, for example Javascript.

Latency. JMeter measures the latency from just before sending the request to just after the first response has been received. Thus the time includes all the processing needed to assemble the request as well as assembling the first part of the response, which in general will be longer than one byte. Protocol analysers (such as Wireshark) measure the time when bytes are actually sent/received over the interface. The JMeter time should be closer to that which is experienced by a browser or other application client.

Connect Time. JMeter measures the time it took to establish the connection, including SSL handshake. Note that connect time is not automatically subtracted from latency. In case of connection error, the metric will be equal to the time it took to face the error, for example in case of Timeout, it should be equal to connection timeout.

所以我的期望是服务器仅测量处理请求和响应所需的时间,而 JMeter 测量所有端到端事务以机智:

  • 正在建立连接(特别是初始 SSL Handshake 可能会很长)
  • 正在向服务器发送数据包
  • 此处服务器开始测量
  • 服务器正在处理请求
  • 此处服务器停止测量
  • 等待第一个数据包到来(延迟)
  • 等待最后一个数据包的到来(耗用时间)

请求来回传输所需的时间can really matter,例如,如果您的路由器出现故障或负载均衡器配置不当,即使实际服务器响应时间很短,用户体验也不会'不顺利。