SpringBoot各类数量限制及超出后抛出的异常

发布于:2024-07-06 ⋅ 阅读:(48) ⋅ 点赞:(0)

前言

在使用SpringBoot开发接口时,动不动的就发生各种超过默认值的限制,这里总结了下SpringBoot默认限制的设置以及可能会发生的异常,便于问题的排查和快速修改默认值。

配置项 配置项说明 默认值 超过大小后抛出的异常
spring.servlet.multipart.max-file-size Max file size
单个上传文件大小
1MB org.springframework.web.multipart
 MaxUploadSizeExceededException
org.apache.tomcat.util.http.fileupload.impl
 FileSizeLimitExceededException
spring.servlet.multipart.max-request-size Max request size.
总上传文件大小
10MB org.springframework.web.multipart
 MaxUploadSizeExceededException
org.apache.tomcat.util.http.fileupload.impl
 SizeLimitExceededException
server.max-http-header-size Maximum size of the HTTP message header 8KB 此值设置过大可能会造成内存溢出
server.tomcat.max-http-form-post-size Maximum size of the form content in any HTTP post request 2MB
server.tomcat.accept-count Maximum queue length for incoming connection requests when all possible request processing threads are in use
当所有可能的请求处理线程都在使用中时,传入连接请求的最大队列长度
100
server.tomcat.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
服务器在任何给定时间接受和处理的最大连接数。一旦达到限制,操作系统仍然可以接受基于“acceptCount”属性的连接
8192
server.tomcat.threads.min-spare Minimum amount of worker threads
工作线程的最小数量,初始化时创建的线程数
10
server.tomcat.threads.max Maximum amount of worker threads
工作线程的最大数量
200
server.tomcat.connection-timeout Amount of time the connector will wait, after accepting a connection, for the request URI line to be presented
连接器在接受连接后等待显示请求 URI 行的时间
20000
server.tomcat.keep-alive-timeout Time to wait for another HTTP request before the connection is closed. When not set the connectionTimeout is used. When set to -1 there will be no timeout
在关闭连接之前等待另一个 HTTP 请求的时间。如果未设置,则使用 connectionTimeout。设置为 -1 时不会超时
20000
server.tomcat.max-keep-alive-requests Maximum number of HTTP requests that can be pipelined before the connection is closed. When set to 0 or 1, keep-alive and pipelining are disabled. When set to -1, an unlimited number of pipelined or keep-alive requests are allowed
在连接关闭之前可以进行流水线处理的最大HTTP请求数量。当设置为0或1时,禁用keep-alive和流水线处理。当设置为-1时,允许无限数量的流水线处理或keep-alive请求
100
server.tomcat.max-swallow-size Maximum amount of request body to swallow 2MB
spring.datasource.hikari.maximum-pool-size hikari线程池最大数量

网站公告

今日签到

点亮在社区的每一天
去签到