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

聊聊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基础:动态路由协议基础

摘要&#xff1a;本文介绍动态路由协议的基本概念&#xff0c;为后续动态路由协议原理课程提供基础和引入。主要讲解常见的动态路由协议、动态路由协议的分类&#xff0c;以及路由协议的功能和自治系统的概念。文章旨在优化标题吸引力&#xff0c;并通过详细的内容夯实读者对动…...

jQuery 第十一章(表单验证插件推荐)

文章目录 前言jValidateZebra FormjQuery.validValValidityValidForm BuilderForm ValidatorProgressionformvalidationjQuery Validation PluginjQuery Validation EnginejQuery ValidateValidarium后言 前言 hello world欢迎来到前端的新世界 &#x1f61c;当前文章系列专栏&…...

SSL握手失败的解决方案

一、SSL握手失败的原因&#xff1a; 1&#xff0c;证书过期&#xff1a;SSL证书有一个有效期限&#xff0c;如果证书过期&#xff0c;就会导致SSL握手失败。 2&#xff0c;证书不被信任&#xff1a;如果网站的SSL证书不被浏览器或操作系统信任&#xff0c;也会导致SSL握手失败…...

K8S客户端一 Rancher的安装

一 安装方式一 通过官网方式安装&#xff1a;官网 sudo docker run --privileged -d --restartunless-stopped -p 80:80 -p 443:443 rancher/rancher:stable访问服务器地址即可&#xff1a;http://192.168.52.128 修改语言 第一次安装会生成密码&#xff0c;查看密码步骤如下…...

websocket与node.js实现

什么是 websocket&#xff1f; websoket 是一种网络通信协议&#xff0c;基于 tcp 连接的全双工通信协议&#xff08;客户端和服务器可以同时收发信息&#xff09;&#xff0c;值得注意的是他不基于 http 协议&#xff0c;websocket 只有在建立连接的时候使用到 http 协议进行…...

postpresql 查询某张表的字段名和字段类型

postpresql 查询某张表的字段名和字段类型 工作中第一次接触postpresql&#xff0c;接触到这么个需求&#xff0c;只是对sql有点了解&#xff0c;于是就网上查阅资料。得知通过系统表可以查询&#xff0c;设计到几张系统表&#xff1a;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&#xff1a;列表的拷贝详解 文章目录 python&#xff1a;列表的拷贝详解方法1&#xff1a;直接赋值&#xff08;&#xff09;方法2&#xff1a;浅拷贝&#xff08;.copy方法&#xff09;格式原理注意 方法3&#xff1a;深拷贝&#xff08;.deepcopy方法&#xff09;格式…...

zip4j压缩使用总结

一、引入依赖 <dependency><groupId>net.lingala.zip4j</groupId><artifactId>zip4j</artifactId><version>1.3.1</version></dependency>二、使用添加文件&#xff08;addFiles&#xff09;的方式生成压缩包 /*** 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是一个软件组件&#xff0c;它构成了实现ARM…...

切换服务器上自己用户目录下的 conda 环境和一个外部的 Conda 环境

如果我们有自己的 Miniconda 安装和一个外部的 Conda 环境&#xff08;比如一个全局安装的 Anaconda&#xff09;&#xff0c;我们可以通过修改 shell 环境来切换使用它们。这通常涉及到更改 PATH 环境变量&#xff0c;以便指向你想要使用的 Conda 安装的可执行文件&#xff1a…...

移动端的自动化基于类实现启动一次应用跑全部用例

1.unittest框架 class TestStringMethods(unittest.TestCase): def setUp(self) -> None: # 每一条测试用例开始前执行 print("setup") def tearDown(self) -> None: # 每一条测试用例结束后执行 print("teardown") …...

Python与设计模式--抽象工厂模式

Python与设计模式–抽象工厂模式 一、快餐点餐系统 想必大家一定见过类似于麦当劳自助点餐台一类的点餐系统吧。在一个大的触摸显示屏上&#xff0c;有三类可以选择的上餐品&#xff1a;汉堡等主餐、小食、饮料。当我们选择好自己需要的食物&#xff0c;支付完成后&#xff0…...

JSP:MVC

一个好的Web应用&#xff1a; 功能完善、易于实现和维护易于扩展等的体系结构 一个Web应用通常分为两个部分&#xff1a; 1. 由界面设计人员完成的表示层&#xff08;主要做网页界面设计&#xff09; 2. 由程序设计人员实现的行为层&#xff08;主要完成本Web应用的各种功能…...

微服务-京东秒杀

1 项目介绍 技术栈 后端 SpringCloud 中Netflix 五大组件&#xff1a; EurekaRibbonHystrixOpenfeignZuul SpringBootSpringSpringMVCMyBatis 数据库 MySQLRedis 前端 html5cssjsjQuery 消息中间件 RabbitMQ 2 项目搭建 项目分析 后端 shop-parent [pom] &#xff08;商…...

「MACOS限定」 如何将文件上传到GitHub仓库

介绍 本期讲解&#xff1a;如何在苹果电脑上上传文件到github远程仓库 注&#xff1a;写的很详细 方便我的朋友可以看懂操作步骤 第一步 在电脑上创建一个新目录&#xff08;文件夹&#xff09; 注&#xff1a;创建GitHub账号、新建github仓库、git下载的步骤这里就不过多赘…...

python opencv 边缘检测(sobel、沙尔算子、拉普拉斯算子、Canny)

python opencv 边缘检测&#xff08;sobel、沙尔算子、拉普拉斯算子、Canny&#xff09; 这次实验&#xff0c;我们分别使用opencv 的 sobel算子、沙尔算子、拉普拉斯算子三种算子取进行边缘检测&#xff0c;然后后面又使用了Canny算法进行边缘检测。 直接看代码&#xff0c;代…...

【Unity入门】鼠标输入和键盘输入

Unity的Input类提供了许多监听用户输入的方法&#xff0c;比如我们常见的鼠标&#xff0c;键盘&#xff0c;手柄等。我们可以用Input类的接口来获取用户的输入信息 一、监听鼠标输入 GetMouseButtonUp 、GetMouseButtonDown、GetMouseButton input.GetMouseButtonDown和 inp…...

KubeSphere 容器平台高可用:环境搭建与可视化操作指南

Linux_k8s篇 欢迎来到Linux的世界&#xff0c;看笔记好好学多敲多打&#xff0c;每个人都是大神&#xff01; 题目&#xff1a;KubeSphere 容器平台高可用&#xff1a;环境搭建与可视化操作指南 版本号: 1.0,0 作者: 老王要学习 日期: 2025.06.05 适用环境: Ubuntu22 文档说…...

OpenLayers 可视化之热力图

注&#xff1a;当前使用的是 ol 5.3.0 版本&#xff0c;天地图使用的key请到天地图官网申请&#xff0c;并替换为自己的key 热力图&#xff08;Heatmap&#xff09;又叫热点图&#xff0c;是一种通过特殊高亮显示事物密度分布、变化趋势的数据可视化技术。采用颜色的深浅来显示…...

Prompt Tuning、P-Tuning、Prefix Tuning的区别

一、Prompt Tuning、P-Tuning、Prefix Tuning的区别 1. Prompt Tuning(提示调优) 核心思想:固定预训练模型参数,仅学习额外的连续提示向量(通常是嵌入层的一部分)。实现方式:在输入文本前添加可训练的连续向量(软提示),模型只更新这些提示参数。优势:参数量少(仅提…...

阿里云ACP云计算备考笔记 (5)——弹性伸缩

目录 第一章 概述 第二章 弹性伸缩简介 1、弹性伸缩 2、垂直伸缩 3、优势 4、应用场景 ① 无规律的业务量波动 ② 有规律的业务量波动 ③ 无明显业务量波动 ④ 混合型业务 ⑤ 消息通知 ⑥ 生命周期挂钩 ⑦ 自定义方式 ⑧ 滚的升级 5、使用限制 第三章 主要定义 …...

关于nvm与node.js

1 安装nvm 安装过程中手动修改 nvm的安装路径&#xff0c; 以及修改 通过nvm安装node后正在使用的node的存放目录【这句话可能难以理解&#xff0c;但接着往下看你就了然了】 2 修改nvm中settings.txt文件配置 nvm安装成功后&#xff0c;通常在该文件中会出现以下配置&…...

【决胜公务员考试】求职OMG——见面课测验1

2025最新版&#xff01;&#xff01;&#xff01;6.8截至答题&#xff0c;大家注意呀&#xff01; 博主码字不易点个关注吧,祝期末顺利~~ 1.单选题(2分) 下列说法错误的是:&#xff08; B &#xff09; A.选调生属于公务员系统 B.公务员属于事业编 C.选调生有基层锻炼的要求 D…...

拉力测试cuda pytorch 把 4070显卡拉满

import torch import timedef stress_test_gpu(matrix_size16384, duration300):"""对GPU进行压力测试&#xff0c;通过持续的矩阵乘法来最大化GPU利用率参数:matrix_size: 矩阵维度大小&#xff0c;增大可提高计算复杂度duration: 测试持续时间&#xff08;秒&…...

高防服务器能够抵御哪些网络攻击呢?

高防服务器作为一种有着高度防御能力的服务器&#xff0c;可以帮助网站应对分布式拒绝服务攻击&#xff0c;有效识别和清理一些恶意的网络流量&#xff0c;为用户提供安全且稳定的网络环境&#xff0c;那么&#xff0c;高防服务器一般都可以抵御哪些网络攻击呢&#xff1f;下面…...

全面解析各类VPN技术:GRE、IPsec、L2TP、SSL与MPLS VPN对比

目录 引言 VPN技术概述 GRE VPN 3.1 GRE封装结构 3.2 GRE的应用场景 GRE over IPsec 4.1 GRE over IPsec封装结构 4.2 为什么使用GRE over IPsec&#xff1f; IPsec VPN 5.1 IPsec传输模式&#xff08;Transport Mode&#xff09; 5.2 IPsec隧道模式&#xff08;Tunne…...

Map相关知识

数据结构 二叉树 二叉树&#xff0c;顾名思义&#xff0c;每个节点最多有两个“叉”&#xff0c;也就是两个子节点&#xff0c;分别是左子 节点和右子节点。不过&#xff0c;二叉树并不要求每个节点都有两个子节点&#xff0c;有的节点只 有左子节点&#xff0c;有的节点只有…...