Springboot-Tomcat配置解析

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.
 */
  • 最小工作线程数。默认10

connection-timeout#

/**
 * Amount of time the connector will wait, after accepting a connection, for the
 * request URI line to be presented.
 */
  • 实际设置的是socket_timeoutsocket调用read()方法阻塞不超过这个时间,否则报java.net.SocketTimeoutException。不设置时,默认为60000ms

总结:#

  • 线程并不是越多越好,需要考虑上下文切换CPU的消耗,CPU时间片分配变少

参考:#

Spring Boot 默认支持的并发量

posted @   FynnWang  阅读(616)  评论(0编辑  收藏  举报
编辑推荐:
· 基于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保姆级教程
more_horiz
keyboard_arrow_up dark_mode palette
选择主题
menu
点击右上角即可分享
微信分享提示