【问题标题】:Why do I get SocketTimeoutException when I have accept-count=100000?当我接受计数 = 100000 时,为什么会收到 SocketTimeoutException?
【发布时间】:2020-02-21 09:00:09
【问题描述】:

我正在使用 JMeter 对我的 Spring Boot 服务器进行负载测试并拥有

application.properties
server.tomcat.accept-count=100000
server.tomcat.max-threads=1000
Application.java
public static void main(String[] args) {
    ApplicationContext context = SpringApplication.run(Application.class, args);
    ServerProperties serverProperties = context.getBean(org.springframework.boot.autoconfigure.web.ServerProperties.class);
    Tomcat tomcat = serverProperties.getTomcat();
    Logger.getLogger(Application.class.getName()).info("acceptCount = " + tomcat.getAcceptCount());
    Logger.getLogger(Application.class.getName()).info("maxConnections = " + tomcat.getMaxConnections());
    Logger.getLogger(Application.class.getName()).info("maxThreads = " + tomcat.getMaxThreads());
Console
2019-10-24 20:22:31.174  INFO 57472 --- [  restartedMain] c.s.s.Application : acceptCount = 100000
2019-10-24 20:22:31.174  INFO 57472 --- [  restartedMain] c.s.s.Application : maxConnections = 10000
2019-10-24 20:22:31.175  INFO 57472 --- [  restartedMain] c.s.s.Application : maxThreads = 1000
loadtest.jmx
    <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
      <boolProp name="LoopController.continue_forever">false</boolProp>
      <stringProp name="LoopController.loops">100</stringProp>
    </elementProp>
    <stringProp name="ThreadGroup.num_threads">10000</stringProp>
    <stringProp name="ThreadGroup.ramp_time">10</stringProp>

(10,000 个用户 x 100 个循环 = 100 万个请求)

在 JMeter View Results Tree 我看到错误:

Response code: Non HTTP response code: java.net.SocketTimeoutException
Response message: Non HTTP response message: Read timed out

Summary Report 显示它在错误停止测试之前获得了多达 11,000 个样本。我不明白,因为接受计数为 100,000,它不应该在它开始拒绝并导致 JMeter 获得 SocketTimeoutException 之前接受队列中的 100,000 个连接吗?


我还尝试了accept-count=10000max-connections=1000,JMeter 获得了多达 8000 个样本,最大时间为 12000 毫秒(HTTP Request 上超时 30 秒)它给出了错误Response code: Non HTTP response code: org.apache.http.conn.HttpHostConnectException Response message: Non HTTP response message: Connect to localhost:8080 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect。在拒绝之前,它至少应该排队 10,000 个连接。

【问题讨论】:

  • accept-count 似乎只是listen() 的积压参数。它与“非 HTTP 响应消息:读取超时”没有任何关系,它仅表示已建立连接(这排除了积压)并且请求已发送,超时未收到响应期间,这可能表明服务器正忙或出现死锁或错误。

标签: java performance spring-boot jmeter load-testing


【解决方案1】:

根据Tomcat documentation

最大连接数

服务器在任何给定时间接受和处理的最大连接数。 达到此数量后,服务器将接受但不处理另一个连接。此附加连接将被阻止,直到正在处理的连接数低于 maxConnections,此时服务器将再次开始接受和处理新连接。请注意,一旦达到限制,操作系统仍可能接受基于在 acceptCount 设置上。默认值因连接器类型而异。对于 NIO 和 NIO2,默认值为 10000。对于 APR/native,默认值为 8192。

因此,我的期望是服务器可以处理 10k 并发连接,并且将上面的连接放入队列中。如果这是您想要的行为 - 只需在 JMeter 的 HTTP Request Defaults 中增加连接/响应超时,设置位于“高级”选项卡下:

【讨论】:

  • 我将超时设置为 30 秒以匹配生产。我认为使用 100,000 accept-connect 它将接受队列中几乎所有的连接而不会超时。我不明白队列、连接、超时、响应的一系列事件。我发现默认值是 100 左右。也许计算机(Windows)不能排队超过这个值,或者真的需要 30+s 才能排队?
  • 您可以使用Windows PerfMonJMeter PerfMon Plugin 来监控负载生成器机器上特定于网络的指标,这可能是您需要增加的情况,即MaxUserPort and TcpTimedWaitDelay settings
猜你喜欢
  • 2021-11-28
  • 1970-01-01
  • 1970-01-01
  • 2017-12-27
  • 2023-02-04
  • 2022-01-26
  • 2022-01-26
  • 2019-12-03
  • 1970-01-01
相关资源
最近更新 更多