关于多线程:JMeter – Windows 7 中负载测试超过 120 个线程时的连接重置和 SSL 错误

JMeter - Connection reset and SSL errors when load test more than 120 threads in windows 7

我正在尝试使用 Windows 7/10 的最新 JMeter 3.3 加载测试网站

当线程数为 120 或以上时,我开始从 F5 收到 SSL 握手失败。

当我将 -Djavax.net.debug=all 添加到执行中时,我发现许多不同的套接字异常:

1
2
3
4
5
6
7
8
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at sun.security.ssl.InputRecord.readFully(Unknown Source)
at sun.security.ssl.InputRecord.read(Unknown Source)
at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)

1
2
3
4
5
6
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at sun.security.ssl.InputRecord.readFully(Unknown Source)
at sun.security.ssl.InputRecord.read(Unknown Source)
at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)

1
2
3
4
5
6
 java.net.SocketException: Connection reset by peer: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(Unknown Source)
at java.net.SocketOutputStream.write(Unknown Source)
at sun.security.ssl.OutputRecord.writeBuffer(Unknown Source)
at sun.security.ssl.OutputRecord.write(Unknown Source)

我遵循答案,但它可能已过时:

Make sure that your HTTP Requests"Implementation" is HTTPClient4 Add
the following lines to user.properties file (located in /bin folder of
your JMeter home)

httpclient4.retrycount=1 hc.parameters.file=hc.parameters In the
hc.parameters file (same location - JMeter's /bin folder) uncomment
the next line:

http.connection.stalecheck$Boolean=true

如何防止这些错误?我尝试调整加速期,但没有帮助。
我还尝试添加此处建议的 EnableConnectionRateLimiting 注册表,但失败了。

我是否达到了 Windows 上 JMeter 的限制,还是可以配置/增加它?

编辑

我尝试使用不同的重试次数和 Java 实现设置 HTTP,但没有改变。

EDIT2

我发现为我的 HTTP 请求使用特定的正确 TLSv1.2 协议解决了这个问题,在 jmeter.properties 中添加以下行:

1
https.socket.protocols=TLSv1.2

增强了使 http 参数可配置的功能。

这使我能够将负载增加到大约 220 个线程,而不会在加速期间出现 SSL 握手错误。


您可能需要调整 Windows tcp 设置以避免达到打开的端口限制。

看这个:

  • https://www.filehold.com/help/technical/Windows-Server-Tuning-to-Prevent-TCPIP-Port-Exhaustion

你需要设置:

  • HKEY_LOCAL_MACHINE\\\\SYSTEM\\\\CurrentControlSet\\\\Services\\\\Tcpip\\\\Parameters\\\\MaxUserPort
    http://technet.microsoft.com/en-us/library/aa995661.aspx
  • HKEY_LOCAL_MACHINE\\\\SYSTEM\\\\CurrentControlSet\\\\Services\\\\Tcpip\\\\Parameters\\\\TcpTimedWaitDelay
    http://technet.microsoft.com/en-us/library/bb397379.aspx
    视窗 2003
    通过在 Windows 注册表项

    上将 TcpTimedWaitDelay TCP/IP 参数设置为 30 秒来减少 TIME_WAIT

  • HKLM\\\\SYSTEM\\\\CurrentControlSet\\\\Services\\\\Tcpip\\\\Parameters,作为 DWORD 值。
    通过将 Windows 注册表项 HKLM\\\\SYSTEM\\\\CurrentControlSet\\\\Services\\\\Tcpip\\\\Parameters 上的 MaxUserPort TCP/IP 参数设置为更高的值(如 32768)来增加临时端口的范围,作为 DWORD 值。这会将端口范围设置为 1024 到 32768。

  • Windows 2008 R2
    通过将 Windows 注册表项 HKLM\\\\SYSTEM\\\\CurrentControlSet\\\\Services\\\\Tcpip\\\\Parameters 上的 TcpTimedWaitDelay TCP/IP 参数设置为 30 秒来减少 TIME_WAIT,作为 DWORD 值。
    通过命令 netsh int ipv4 set dynamicportrange tcp start=32767 num=65535 将 dynamicportrange 设置为更高的值来增加临时端口的范围,这会将端口范围设置为从 32768 到 65535。