Springboot-Tomcat配置解析#
SpringBoot版本:2.2.2.RELEASE#
server :
tomcat :
max-connections : 10000
max-threads : 200
accept-count : 100
min-spare-threads : 10
connection-timeout : 30s
max-connections#
/**
* Maximum number of connections that the server accepts and processes at any
* given time. Once the limit has been reached, the operating system may still
* accept connections based on the "acceptCount" property.
*/
tomcat可建立的最大连接数,超过则放入accept-count队列中。默认10000
accept-count#
/**
* Maximum queue length for incoming connection requests when all possible request
* processing threads are in use.
*/
超过max-connections的连接请求放入队列
max-threads#
/**
* Maximum amount of worker threads.
*/
最大工作线程数。默认200。
BIO模式。 一个线程处理一个连接
NIO模式。 一个线程处理多个连接
min-spare-threads#
/**
* Minimum amount of worker threads.
*/
connection-timeout#
/**
* Amount of time the connector will wait, after accepting a connection, for the
* request URI line to be presented.
*/
实际设置的是socket_timeout 。socket 调用read() 方法阻塞不超过这个时间,否则报java.net.SocketTimeoutException
。不设置时,默认为60000ms
总结:#
线程并不是越多越好,需要考虑上下文切换CPU的消耗,CPU时间片分配变少
参考:#
Spring Boot 默认支持的并发量
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· Vue3状态管理终极指南:Pinia保姆级教程