当前位置: 代码网 > it编程>编程语言>Java > SpringBoot服务器配置全过程

SpringBoot服务器配置全过程

2025年11月14日 Java 我要评论
1. springboot headerspringboot默认header的最大长度是8kb。通过org.springframework.boot.autoconfigure.web.serverp

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

总结

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

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2026  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com