聊聊tomcat的connection-timeout
序
本文主要研究一下tomcat的connection-timeout
ServerProperties.Tomcat
org/springframework/boot/autoconfigure/web/ServerProperties.java
public static class Tomcat {/*** Access log configuration.*/private final Accesslog accesslog = new Accesslog();/*** Thread related configuration.*/private final Threads threads = new Threads();/*** Tomcat base directory. If not specified, a temporary directory is used.*/private File basedir;/*** Delay between the invocation of backgroundProcess methods. If a duration suffix* is not specified, seconds will be used.*/@DurationUnit(ChronoUnit.SECONDS)private Duration backgroundProcessorDelay = Duration.ofSeconds(10);/*** Maximum size of the form content in any HTTP post request.*/private DataSize maxHttpFormPostSize = DataSize.ofMegabytes(2);/*** Maximum amount of request body to swallow.*/private DataSize maxSwallowSize = DataSize.ofMegabytes(2);/*** Whether requests to the context root should be redirected by appending a / to* the path. When using SSL terminated at a proxy, this property should be set to* false.*/private Boolean redirectContextRoot = true;/*** Whether HTTP 1.1 and later location headers generated by a call to sendRedirect* will use relative or absolute redirects.*/private boolean useRelativeRedirects;/*** Character encoding to use to decode the URI.*/private Charset uriEncoding = StandardCharsets.UTF_8;/*** 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.*/private int maxConnections = 8192;/*** Maximum queue length for incoming connection requests when all possible request* processing threads are in use.*/private int acceptCount = 100;/*** Maximum number of idle processors that will be retained in the cache and reused* with a subsequent request. When set to -1 the cache will be unlimited with a* theoretical maximum size equal to the maximum number of connections.*/private int processorCache = 200;/*** Comma-separated list of additional patterns that match jars to ignore for TLD* scanning. The special '?' and '*' characters can be used in the pattern to* match one and only one character and zero or more characters respectively.*/private List<String> additionalTldSkipPatterns = new ArrayList<>();/*** Comma-separated list of additional unencoded characters that should be allowed* in URI paths. Only "< > [ \ ] ^ ` { | }" are allowed.*/private List<Character> relaxedPathChars = new ArrayList<>();/*** Comma-separated list of additional unencoded characters that should be allowed* in URI query strings. Only "< > [ \ ] ^ ` { | }" are allowed.*/private List<Character> relaxedQueryChars = new ArrayList<>();/*** Amount of time the connector will wait, after accepting a connection, for the* request URI line to be presented.*/private Duration connectionTimeout;/*** Static resource configuration.*/private final Resource resource = new Resource();/*** Modeler MBean Registry configuration.*/private final Mbeanregistry mbeanregistry = new Mbeanregistry();/*** Remote Ip Valve configuration.*/private final Remoteip remoteip = new Remoteip();//......}
springboot的ServerProperties.Tomcat定义了connectionTimeout属性,用于指定接受连接之后等待uri的时间
customizeConnectionTimeout
org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizer.java
private void customizeConnectionTimeout(ConfigurableTomcatWebServerFactory factory, Duration connectionTimeout) {factory.addConnectorCustomizers((connector) -> {ProtocolHandler handler = connector.getProtocolHandler();if (handler instanceof AbstractProtocol) {AbstractProtocol<?> protocol = (AbstractProtocol<?>) handler;protocol.setConnectionTimeout((int) connectionTimeout.toMillis());}});}
customizeConnectionTimeout将connectionTimeout写入到AbstractProtocol
AbstractProtocol
org/apache/coyote/AbstractProtocol.java
public void setConnectionTimeout(int timeout) {endpoint.setConnectionTimeout(timeout);}
AbstractProtocol将timeout设置到endpoint
AbstractEndpoint
org/apache/tomcat/util/net/AbstractEndpoint.java
public void setConnectionTimeout(int soTimeout) { socketProperties.setSoTimeout(soTimeout); }/*** Keepalive timeout, if not set the soTimeout is used.*/private Integer keepAliveTimeout = null;public int getKeepAliveTimeout() {if (keepAliveTimeout == null) {return getConnectionTimeout();} else {return keepAliveTimeout.intValue();}}
AbstractEndpoint将timeout设置到socketProperties的soTimeout,另外它的getKeepAliveTimeout方法在keepAliveTimeout为null的时候,使用的是getConnectionTimeout
Http11Processor
org/apache/coyote/http11/Http11Processor.java
public SocketState service(SocketWrapperBase<?> socketWrapper)throws IOException {RequestInfo rp = request.getRequestProcessor();rp.setStage(org.apache.coyote.Constants.STAGE_PARSE);// Setting up the I/OsetSocketWrapper(socketWrapper);// FlagskeepAlive = true;openSocket = false;readComplete = true;boolean keptAlive = false;SendfileState sendfileState = SendfileState.DONE;while (!getErrorState().isError() && keepAlive && !isAsync() && upgradeToken == null &&sendfileState == SendfileState.DONE && !protocol.isPaused()) {// Parsing the request headertry {if (!inputBuffer.parseRequestLine(keptAlive, protocol.getConnectionTimeout(),protocol.getKeepAliveTimeout())) {if (inputBuffer.getParsingRequestLinePhase() == -1) {return SocketState.UPGRADING;} else if (handleIncompleteRequestLineRead()) {break;}}//......}//......}//......}
Http11Processor的service方法在执行inputBuffer.parseRequestLine时传入了keptAlive、protocol.getConnectionTimeout()、protocol.getKeepAliveTimeout()参数
小结
springboot提供了tomcat的connection-timeout参数配置,其配置的是socket timeout,不过springboot没有提供对keepAliveTimeout的配置,它默认是null,读取的是connection timeout的配置。
相关文章:
聊聊tomcat的connection-timeout
序 本文主要研究一下tomcat的connection-timeout ServerProperties.Tomcat org/springframework/boot/autoconfigure/web/ServerProperties.java public static class Tomcat {/*** Access log configuration.*/private final Accesslog accesslog new Accesslog();/*** Th…...
HCIA-RS基础:动态路由协议基础
摘要:本文介绍动态路由协议的基本概念,为后续动态路由协议原理课程提供基础和引入。主要讲解常见的动态路由协议、动态路由协议的分类,以及路由协议的功能和自治系统的概念。文章旨在优化标题吸引力,并通过详细的内容夯实读者对动…...
jQuery 第十一章(表单验证插件推荐)
文章目录 前言jValidateZebra FormjQuery.validValValidityValidForm BuilderForm ValidatorProgressionformvalidationjQuery Validation PluginjQuery Validation EnginejQuery ValidateValidarium后言 前言 hello world欢迎来到前端的新世界 😜当前文章系列专栏&…...
SSL握手失败的解决方案
一、SSL握手失败的原因: 1,证书过期:SSL证书有一个有效期限,如果证书过期,就会导致SSL握手失败。 2,证书不被信任:如果网站的SSL证书不被浏览器或操作系统信任,也会导致SSL握手失败…...
K8S客户端一 Rancher的安装
一 安装方式一 通过官网方式安装:官网 sudo docker run --privileged -d --restartunless-stopped -p 80:80 -p 443:443 rancher/rancher:stable访问服务器地址即可:http://192.168.52.128 修改语言 第一次安装会生成密码,查看密码步骤如下…...
websocket与node.js实现
什么是 websocket? websoket 是一种网络通信协议,基于 tcp 连接的全双工通信协议(客户端和服务器可以同时收发信息),值得注意的是他不基于 http 协议,websocket 只有在建立连接的时候使用到 http 协议进行…...
postpresql 查询某张表的字段名和字段类型
postpresql 查询某张表的字段名和字段类型 工作中第一次接触postpresql,接触到这么个需求,只是对sql有点了解,于是就网上查阅资料。得知通过系统表可以查询,设计到几张系统表:pg_class、pg_attrubute、information_sc…...
jetson NX部署Yolov8
一,事情起因,由于需要对无人机机载识别算法进行更新,所以需要对yolov8算法进行部署到边缘端。 二,环境安装 安装虚拟环境管理工具,这个根据个人喜好。 我们需要选择能够在ARM架构上运行的conda,这里我们选择conda-forge 下载地址 安装即可 剩下的就是和conda 创建虚拟…...
【论文阅读笔记】Emu Edit: Precise Image Editing via Recognition and Generation Tasks
【论文阅读笔记】Emu Edit: Precise Image Editing via Recognition and Generation Tasks 论文阅读笔记论文信息摘要背景方法结果额外 关键发现作者动机相关工作1. 使用输入和编辑图像的对齐和详细描述来执行特定的编辑2. 另一类图像编辑模型采用输入掩码作为附加输入 。3. 为…...
python:列表的拷贝详解
python:列表的拷贝详解 文章目录 python:列表的拷贝详解方法1:直接赋值()方法2:浅拷贝(.copy方法)格式原理注意 方法3:深拷贝(.deepcopy方法)格式…...
zip4j压缩使用总结
一、引入依赖 <dependency><groupId>net.lingala.zip4j</groupId><artifactId>zip4j</artifactId><version>1.3.1</version></dependency>二、使用添加文件(addFiles)的方式生成压缩包 /*** Author wan…...
【第一部分:概述】ARM Realm Management Monitor specification
目录 概述机密计算系统软件组成MonitorRealmRealm Management Monitor (RMM)Virtual Machine (VM)HypervisorSecure Partition Manager (SPM)Trusted OS (TOS)Trusted Application (TA) Realm Management Monitor 参考文献 概述 RMM是一个软件组件,它构成了实现ARM…...
切换服务器上自己用户目录下的 conda 环境和一个外部的 Conda 环境
如果我们有自己的 Miniconda 安装和一个外部的 Conda 环境(比如一个全局安装的 Anaconda),我们可以通过修改 shell 环境来切换使用它们。这通常涉及到更改 PATH 环境变量,以便指向你想要使用的 Conda 安装的可执行文件:…...
移动端的自动化基于类实现启动一次应用跑全部用例
1.unittest框架 class TestStringMethods(unittest.TestCase): def setUp(self) -> None: # 每一条测试用例开始前执行 print("setup") def tearDown(self) -> None: # 每一条测试用例结束后执行 print("teardown") …...
Python与设计模式--抽象工厂模式
Python与设计模式–抽象工厂模式 一、快餐点餐系统 想必大家一定见过类似于麦当劳自助点餐台一类的点餐系统吧。在一个大的触摸显示屏上,有三类可以选择的上餐品:汉堡等主餐、小食、饮料。当我们选择好自己需要的食物,支付完成后࿰…...
JSP:MVC
一个好的Web应用: 功能完善、易于实现和维护易于扩展等的体系结构 一个Web应用通常分为两个部分: 1. 由界面设计人员完成的表示层(主要做网页界面设计) 2. 由程序设计人员实现的行为层(主要完成本Web应用的各种功能…...
微服务-京东秒杀
1 项目介绍 技术栈 后端 SpringCloud 中Netflix 五大组件: EurekaRibbonHystrixOpenfeignZuul SpringBootSpringSpringMVCMyBatis 数据库 MySQLRedis 前端 html5cssjsjQuery 消息中间件 RabbitMQ 2 项目搭建 项目分析 后端 shop-parent [pom] (商…...
「MACOS限定」 如何将文件上传到GitHub仓库
介绍 本期讲解:如何在苹果电脑上上传文件到github远程仓库 注:写的很详细 方便我的朋友可以看懂操作步骤 第一步 在电脑上创建一个新目录(文件夹) 注:创建GitHub账号、新建github仓库、git下载的步骤这里就不过多赘…...
python opencv 边缘检测(sobel、沙尔算子、拉普拉斯算子、Canny)
python opencv 边缘检测(sobel、沙尔算子、拉普拉斯算子、Canny) 这次实验,我们分别使用opencv 的 sobel算子、沙尔算子、拉普拉斯算子三种算子取进行边缘检测,然后后面又使用了Canny算法进行边缘检测。 直接看代码,代…...
【Unity入门】鼠标输入和键盘输入
Unity的Input类提供了许多监听用户输入的方法,比如我们常见的鼠标,键盘,手柄等。我们可以用Input类的接口来获取用户的输入信息 一、监听鼠标输入 GetMouseButtonUp 、GetMouseButtonDown、GetMouseButton input.GetMouseButtonDown和 inp…...
盘古信息PCB行业解决方案:以全域场景重构,激活智造新未来
一、破局:PCB行业的时代之问 在数字经济蓬勃发展的浪潮中,PCB(印制电路板)作为 “电子产品之母”,其重要性愈发凸显。随着 5G、人工智能等新兴技术的加速渗透,PCB行业面临着前所未有的挑战与机遇。产品迭代…...
ffmpeg(四):滤镜命令
FFmpeg 的滤镜命令是用于音视频处理中的强大工具,可以完成剪裁、缩放、加水印、调色、合成、旋转、模糊、叠加字幕等复杂的操作。其核心语法格式一般如下: ffmpeg -i input.mp4 -vf "滤镜参数" output.mp4或者带音频滤镜: ffmpeg…...
Java + Spring Boot + Mybatis 实现批量插入
在 Java 中使用 Spring Boot 和 MyBatis 实现批量插入可以通过以下步骤完成。这里提供两种常用方法:使用 MyBatis 的 <foreach> 标签和批处理模式(ExecutorType.BATCH)。 方法一:使用 XML 的 <foreach> 标签ÿ…...
离线语音识别方案分析
随着人工智能技术的不断发展,语音识别技术也得到了广泛的应用,从智能家居到车载系统,语音识别正在改变我们与设备的交互方式。尤其是离线语音识别,由于其在没有网络连接的情况下仍然能提供稳定、准确的语音处理能力,广…...
数据结构:递归的种类(Types of Recursion)
目录 尾递归(Tail Recursion) 什么是 Loop(循环)? 复杂度分析 头递归(Head Recursion) 树形递归(Tree Recursion) 线性递归(Linear Recursion)…...
LangChain 中的文档加载器(Loader)与文本切分器(Splitter)详解《二》
🧠 LangChain 中 TextSplitter 的使用详解:从基础到进阶(附代码) 一、前言 在处理大规模文本数据时,特别是在构建知识库或进行大模型训练与推理时,文本切分(Text Splitting) 是一个…...
在Zenodo下载文件 用到googlecolab googledrive
方法:Figshare/Zenodo上的数据/文件下载不下来?尝试利用Google Colab :https://zhuanlan.zhihu.com/p/1898503078782674027 参考: 通过Colab&谷歌云下载Figshare数据,超级实用!!࿰…...
算法250609 高精度
加法 #include<stdio.h> #include<iostream> #include<string.h> #include<math.h> #include<algorithm> using namespace std; char input1[205]; char input2[205]; int main(){while(scanf("%s%s",input1,input2)!EOF){int a[205]…...
深度解析云存储:概念、架构与应用实践
在数据爆炸式增长的时代,传统本地存储因容量限制、管理复杂等问题,已难以满足企业和个人的需求。云存储凭借灵活扩展、便捷访问等特性,成为数据存储领域的主流解决方案。从个人照片备份到企业核心数据管理,云存储正重塑数据存储与…...
CSS 工具对比:UnoCSS vs Tailwind CSS,谁是你的菜?
在现代前端开发中,Utility-First (功能优先) CSS 框架已经成为主流。其中,Tailwind CSS 无疑是市场的领导者和标杆。然而,一个名为 UnoCSS 的新星正以其惊人的性能和极致的灵活性迅速崛起。 这篇文章将深入探讨这两款工具的核心理念、技术差…...
