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 # 缓冲区大小

总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。
发表评论