当前位置: 首页 > news >正文

SpringBoot 服务器配置

1. SpringBoot Header

Springboot默认header的最大长度是8KB。通过

org.springframework.boot.autoconfigure.web.ServerProperties可以看到

在SpringBoot中,可以在配置文件中修改请求头最大限制。

在properties文件中:

server.maxhttprequestheadersize=100MB

2. SpringBoot 默认同时可以处理的最大连接数

Spring Boot 的默认最大连接数取决于其内置的服务器(如 Tomcat、Jetty 或 Undertow)以及相关配置。

Tomcat(默认服务器):

通过org.springframework.boot.autoconfigure.web.ServerProperties.Tomcat分析

 

Spring Boot 2.x/3.x 默认使用 Tomcat,其核心连接参数如下:

  • 最大连接数(maxConnections):8192(Tomcat 10+ 默认值)

              含义:服务器可接受的最大连接数(包括等待处理的连接)。

  • 最大工作线程数(maxThreads):200

            含义:同时处理请求的最大线程数。

  • 最大等待队列长度(acceptCount):100

           含义:当所有线程都在处理请求时,可放入队列等待的最大请求数。

修改配置:

server.tomcat.maxthreads=500
server.tomcat.maxconnections=10000
server.tomcat.acceptcount=200

Jetty:

通过org.springframework.boot.autoconfigure.web.ServerProperties.Jetty分析

  • 最大连接数(maxConnections):无上限
  • 最大工作线程数(maxThreads):200
  • 最大队列长度(acceptQueueSize):无上限

设置Jetty:

server.jetty.threads.max=200
server.jetty.threads.min=8
server.jetty.threads.idletimeout=60000ms
server.jetty.maxconnections=8192

Undertow:

  • 最大工作线程数(io-threads × worker-threads):

                        io-threads:2 × CPU核心数(默认)
                        worker-threads:200(默认)
                        总线程数 = io-threads × worker-threads

  • 每个连接的直接缓冲区大小(direct-buffers):true(默认启用)
server.undertow.threads.io=8       # I/O线程数(默认CPU核心数×2)
server.undertow.threads.worker=256 # 工作线程数
server.undertow.buffersize=1024   # 缓冲区大小

参考:

SpringBoot 默认同时可以处理的最 大连接数是多少?_springboot 最大连接数-CSDN博客

http://www.lryc.cn/news/608450.html

相关文章:

  • 面经——电子电路技术知识详解
  • 【Python3教程】Python3高级篇之网络编程
  • 文心4.5开源测评:国产大模型的轻量化革命与全栈突破
  • GaussDB 约束的使用举例
  • 高效轻量的C++ HTTP服务:cpp-httplib使用指南
  • Redis核心机制与实践深度解析:从持久化到分布式锁
  • 路面障碍物识别漏检率↓76%:陌讯多模态融合算法实战解析
  • 基于 LFU 策略的存储缓存系统设计与实现
  • 人工智能之数学基础:离散型随机事件概率(古典概型)
  • 兰空图床部署教程
  • LQR个人笔记
  • Unity_数据持久化_C#处理XML文件
  • ollama 多实例部署
  • 睡岗识别误报率↓76%:陌讯动态时序融合算法实战解析
  • JP3-3-MyClub后台后端(三)
  • 小迪23-28~31-js简单回顾
  • 解决mac在安装nvm过程中可能遇到的一些问题
  • 小迪23年-22~27——php简单回顾(2)
  • (nice!!!)(LeetCode 每日一题) 2561. 重排水果 (哈希表 + 贪心)
  • 【自动化运维神器Ansible】YAML支持的数据类型详解:构建高效Playbook的基石
  • 译| Netflix内容推荐模型的一些改进方向
  • Tlias案例-登录 退出 打包部署
  • Leetcode 11 java
  • 论文笔记:Bundle Recommendation and Generation with Graph Neural Networks
  • (1-8-1) Java -XML
  • [ LeetCode-----盛最多的水]
  • 如何快速解决PDF解密新方法?
  • SpringBoot启动项目详解
  • 丝杆升降机在物流运输领域有哪些应用场景
  • 大模型Agent记忆的主流技术与优缺点解析