学技术学英文:Tomcat的线程模型调优

导读:

tomcat 线程调优关键需要理解下面这几个参数:

1. maxConnections

  • 描述:指定服务器能够同时接受和处理的最大连接数。也就是说,服务器在任何时候都能处理的最大并发连接数。
  • 作用:限制服务器在任何给定时间点能够处理的最大连接数量,以防止资源耗尽和系统过载。

2. acceptCount

  • 描述:指定当所有处理请求的线程都在忙碌时,可以排队等待处理的最大请求数。一旦这个队列满了,新进来的请求将会被拒绝。
  • 作用:控制在所有线程都忙碌时可以排队等待处理的最大请求数,避免服务器过载。

3. maxThreads

  • 描述:指定服务器能够创建的最大请求处理线程数。这些线程用于实际处理客户端的请求。
  • 作用:确保服务器在高负载情况下有足够的线程来处理并发请求,从而提高处理能力和响应速度。

4. minSpareThreads

  • 描述:指定保持空闲状态的最小请求处理线程数。这些空闲线程始终可用,以便快速响应新的请求。
  • 作用:确保在任何时候都有足够的空闲线程来处理突然增加的请求量,从而提供更好的响应时间。

Tomcat is a popular open source servlet container in the Java ecosystem. Tomcat is the default container for spring boot web applications (spring boot also supports other containers). In this post I will describe the tomcat threading model. 

Tomcat follows the thread per request model, which means tomcat will assign a thread to each incoming request. Tomcot will maintain a thread pool, a free thread will be picked from the thread and assigned to the request. If there are no free threads available in the pool, tomcat will create a new thread if the thread pool size is below the maximum allowed. If the pool size has already reached maximum size, then the request will be queued.  

What is the optimal thread pool size

Tomcat default values for max pool size 200, The optimal pool size depends on the application characteristics. One can profile the application with various pool sizes and pick the one which gives best performance. 

If the application is CPU intensive, then the number of concurrent requests that can be served will be limited by the number of CPU cores available in the system. Increasing the thread count for CPU intensive applications will not result in increased throughput, the system will spend most of the time in context switching than doing the actual work. 

If the application is mostly doing calls to DB and serving the results to clients, then the max pool size can be much more than the number of CPU cores of the system. For spingboot deployments, following properties can be used to control the worker pool size.

For versions older than 2.3.x

server.tomcat.min-spare-threads=10

server.tomcat.max-threads=200

From 2.3.x, they became

server.tomcat.threads.min-spare=10

server.tomcat.threads.max=200

If the applications have endpoints with different characteristics, it might be a good idea to group these endpoints based on characteristics and have different deployments. For example if the application has analytic end points that take 1 second to respond, clubbing them together with endpoints that have 10ms response time may result in queue building and idle CPU ( this happens because the analytics endpoint will hold the thread until the response comes back from the DB). Large queue build up will cause spikes in latencies for clients and may also cause timeouts. The queue size can be controlled with max-connections and accept-count parameters. Tomcat will keep accepting the new connections until max-connections limit is reached, once this limit is reached connections will not be accepted by tomcat, hence they will be queued at OS level. OS will queue the connection until accept-count is reached, then connections will be refused.

server.tomcat.max-connections=8192

server.tomcat.accept-count=100

If requests takes on an average T milliseconds (when the thread pool is at its max size), then RPM that can handled by the system can be computed by the following formula

RPM =  (60000/ (Tavg)) * thread_pool_size

If each request takes 100ms, and we have 10 threads, then we can serve up to 6K RPM. If more requests come in then tomcat will start queuing the requests. 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/66111.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【微信小程序获取用户手机号

微信小程序获取用户手机号有2种,一种是前端自己解密,一种是获取后发给后端,后端去解密 重点:要在微信公众平台设置里面绑定微信开放平台账号,不然反解不出来用户手机号上代码: <button style"font-size: 16px;" open-type"getPhoneNumber" getphonenumb…

单片机-静动态数码管实验

P0控制数码管 &#xff0c;P0低电平 P1,P2,P3高电平 1、静态数码管 需求&#xff1a;数码管显示0&#xff0c;即让p0端口输出数字0的段码0x3f(共阴) #include "reg52.h" typedef unsigned int u16; typedef unsigned char u8; //数码管显示数字的数组 共阴极 …

创龙3588——debian根文件系统制作

文章目录 build.sh debian 执行流程build.sh源码流程 30-rootfs.sh源码流程 mk-rootfs-bullseys.sh源码流程 mk-sysroot.sh源码流程 mk-image.sh源码流程 post-build.sh 大致流程系统制作步骤 build.sh debian 执行流程 build.sh 源码 run_hooks() {DIR"$1"shiftf…

管理者管理上班摸鱼

管理者管理上班摸鱼的问题,实际上涉及到员工工作态度、时间管理、团队文化等方面。以下是一些有效的管理策略: 明确期望与目标 确保每个员工了解他们的工作职责、目标以及衡量工作表现的标准。明确的期望有助于避免模糊空间,让员工知道自己的任务和责任,不容易找到摸鱼的借…

聆听音乐 1.5.9 | 畅听全网音乐,支持无损音质下载

聆听音乐手机版是面向广大音乐爱好者的移动应用程序&#xff0c;用户可以随时随地通过手机享受丰富的音乐资源。它提供了多种魅力功能&#xff0c;让用户在手机上畅享更舒适的音乐体验&#xff0c;每位用户都能享受精彩纷呈的收听体验。此外&#xff0c;软件还支持无损音质音乐…

day-104 组合总和 Ⅳ

思路 动态规划 解题过程 假设dfs(target)表示组成target的组合数&#xff0c;可得转换方程dfs(target)dfs(target-nums[0])dfs(target-nums[1])…以此类推 注意&#xff1a;nums[i]需要小于等于当前的target Code class Solution {public int combinationSum4(int[] nums, i…

汽车燃油软件标定测试

油箱测试 确定油箱的参数&#xff1a; 总容积&#xff0c;额定容积&#xff0c;不可用容积等。油泵测试&#xff08;静态&#xff09; 分为加油测试&#xff0c;减油测试&#xff0c;1L或者500ml增减&#xff1b; 分别测试油泵的阻值输出&#xff0c;类似&#xff1a; 油量 阻…

MATLAB中binopdf函数用法

目录 语法 说明 示例 计算并绘制二项概率密度函数 binopdf函数的功能是计算二项概率密度函数。 语法 y binopdf(x,n,p) 说明 y binopdf(x,n,p) 使用 n 中对应的试验次数和 p 中每次试验的成功概率&#xff0c;计算 x 中每个值处的二项概率密度函数。 x、n 和 p 可以是…

linux tar 文件解压压缩

文件压缩和解压 tar -c: 建立压缩档案 -x&#xff1a;解压 -t&#xff1a;查看内容 -r&#xff1a;向压缩归档文件末尾追加文件 -u&#xff1a;更新原压缩包中的文件 -z&#xff1a;有gzip属性的 -j&#xff1a;有bz2属性的 -v&#xff1a;显示所有过程 -O&#xff1a;…

Spring Boot日志处理

文章目录 Spring Boot日志处理1. 日志存入数据库&#xff08;AOP&#xff09;2. 日志控制台打印与写入文件&#xff08;logback&#xff09; Spring Boot日志处理 1. 日志存入数据库&#xff08;AOP&#xff09; 引入aop依赖 <dependency><groupId>org.springfram…

vite6+vue3+ts+prettier+eslint9配置前端项目(后台管理系统、移动端H5项目通用配置)

很多小伙伴苦于无法搭建一个规范的前端项目&#xff0c;导致后续开发不规范&#xff0c;今天给大家带来一个基于Vite6TypeScriptVue3ESlint9Prettier的搭建教程。 目录 一、基础配置1、初始化项目2、代码质量风格的统一2.1、配置prettier2.2、配置eslint2.3、配置typescript 3、…

GitHub的简单操作

引言 今天开始就要开始做项目了&#xff0c;上午是要把git搭好。搭的过程中遇到好多好多的问题。下面就说一下git的简单操作流程。我们是使用的GitHub,下面也就以这个为例了 一、GitHub账号的登录注册 https://github.com/ 通过这个网址可以来到GitHub首页 点击中间绿色的S…

详细的一条SQL语句的执行流程

SQL 语句的执行流程会因数据库管理系统的不同而略有差异&#xff0c;但一般来说&#xff0c;主要包括以下几个阶段&#xff1a; 查询解析 词法分析&#xff1a;数据库系统首先将输入的 SQL 语句按字符流进行扫描&#xff0c;依据词法规则把它分割成一个个的单词&#xff0c;如…

基于CentOS的Docker + Nginx + Gitee + Jenkins部署总结

一、部署环境概述 本文阐述在CentOS系统上运用PowerShell命令部署Docker、Nginx、Gitee&#xff08;文中未详细提及Gitee相关配置&#xff0c;可根据实际情况与其他代码托管平台类比&#xff09;和Jenkins&#xff0c;实现前端自动化部署的流程&#xff0c;包含从系统环境准备…

OpenCV调整图像亮度和对比度

【欢迎关注编码小哥&#xff0c;学习更多实用的编程方法和技巧】 1、基本方法---线性变换 // 亮度和对比度调整 cv::Mat adjustBrightnessContrast(const cv::Mat& src, double alpha, int beta) {cv::Mat dst;src.convertTo(dst, -1, alpha, beta);return dst; }// 使用…

《机器学习》——逻辑回归(下采样)

文章目录 什么是下采样&#xff1f;为什么在逻辑回归中要使用下采样&#xff1f;使用下采样和不使用下采样的区别实例1、实例内容2、实例步骤 什么是下采样&#xff1f; 下采样&#xff08;Down - Sampling&#xff09;是一种数据处理技术&#xff0c;主要用于处理数据集中不同…

Python实现接口签名调用

目录: 1、第三方接口签名调用2、调用结果 1、第三方接口签名调用 import json import requests import hashlib import time import hmac access_key xxxxxxxxxxxxxxx secret_key xxxxxxxxxxxxxxx # 应用信息 def _wps4_sig(method, url, date, body): print(body)if bod…

什么是.net framework,什么是.net core,什么是.net5~8,版本对应关系

我不知道有多少人和我一样&#xff0c;没学习过.netCore&#xff0c;想要学习&#xff0c;但是版本号太多就蒙了&#xff0c;不知道学什么了&#xff0c;这里解释下各个版本的关系 我们一般开始学习微软的时候&#xff0c;都是开始学习的.netframework&#xff0c;常用的就是4…

对比式机器学习揭示了跨物种共享和特异性的脑功能结构|文献速递-视觉大模型医疗图像应用

Title 题目 Contrastive machine learning reveals species -shared and -specific brain functional architecture 对比式机器学习揭示了跨物种共享和特异性的脑功能结构 01 文献速递介绍 猕猴被广泛作为人类的动物模型&#xff0c;用于研究大脑和行为的关键方面&#xf…

中药和西药的区别

中药和西药的区别 一、定义与来源 &#xff08;一&#xff09;中药 中药主要是在中国传统医学理论指导下用于预防、诊断、治疗疾病或调节人体机能的药物。它的来源广泛&#xff0c;包括植物药、动物药、矿物药等。植物药是中药的主要组成部分&#xff0c;例如人参&#xff0…