Tomcat日志出现连接超时的定位与处理
一、先快速定位超时发生在哪一段链路
二、常见根因与对应处理要点
三、关键配置示例与建议值
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
maxThreads="200"
minSpareThreads="25"
acceptCount="100"
maxKeepAliveRequests="100"
redirectPort="8443" />
location / {
proxy_pass http://tomcat_servers;
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
send_timeout 60s;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
server:
tomcat:
threads:
max: 800
min-spare: 100
accept-count: 100
connection-timeout: 5000
max-connections: 8192
spring:
datasource:
hikari:
maximum-pool-size: 32
minimum-idle: 8
connection-timeout: 30000
idle-timeout: 600000
max-lifetime: 1800000
validation-query: SELECT 1
test-while-idle: true
test-on-borrow: true
四、按场景的排查与修复步骤
五、监控与持续优化