【发布时间】:2018-12-03 01:14:24
【问题描述】:
如何增加超时,以便在处理响应之前,请求不会超时?
Spring Boot 中的 Tomcat 设置:
server.tomcat.max-connections=2000
server.tomcat.max-threads=200
server.connection-timeout=1200000
在 15 秒的过程中,每秒请求被提高到 constantUsersPerSec(20) during (15) 到 300,并且所有请求都得到了处理,如下图所示 gatling(蓝色)。
scn.inject(
constantUsersPerSec(20) during (15),
)
这是由于 max-connections = 2000 使用 200 工作线程处理了 300 个请求。
Controller 是用 Spring MVC 编写的,它返回 DeferredResult,它会进行异步请求处理,因此一旦处理完响应就会恢复响应。
但即使 server.connection-timeout 设置为高数 1200000 也有很多 503 接近尾声(红色)
> status.find.in(200,304,201,202,203,204,205,206,207,208,209), b 78 (100.0%)
ut actually found 503
Gatling.conf 也设置为增加超时:
timeOut {
simulation = 8640000 # Absolute timeout, in seconds, of a simulation
}
ahc {
#keepAlive = true # Allow pooling HTTP connections (keep-alive header automatically added)
connectTimeout = 600000 # Timeout when establishing a connection
handshakeTimeout = 600000 # Timeout when performing TLS hashshake
pooledConnectionIdleTimeout = 600000 # Timeout when a connection stays unused in the pool
readTimeout = 600000 # Timeout when a used connection stays idle
#maxRetry = 2 # Number of times that a request should be tried again
requestTimeout = 600000
【问题讨论】:
-
ahc 在 http 块内吗?
-
是的,在 gatling.conf 的 http 块内 - core.timeout 和 http.ahc
-
检查这个属性:spring.mvc.async.request-timeout= #异步请求处理超时前的时间量。
标签: java spring spring-boot tomcat gatling