【发布时间】: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=10000、max-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