当前位置:网站首页>Relationship between application software threads and CPU cores
Relationship between application software threads and CPU cores
2022-04-21 07:45:00 【Think of the source after drinking water 09】
As a general rule , It is believed that the empirical value of thread pool size should be set as follows :( among N by CPU The number of )
- If it is CPU Intensive application , Then the thread pool size is set to N+1
- If it is IO Intensive application , Then the thread pool size is set to 2N+1( because io When reading data or caching , Thread waiting , At this time, if you open more threads , Can effectively improve cpu utilization )
If only one application is deployed on a server and there is only one thread pool , So this estimate may be reasonable , It needs to be tested and verified by itself .
however ,IO Optimization , Such an estimation formula may be more suitable for :
The best number of threads = (( Thread wait time + Threads CPU Time )/ Threads CPU Time )* CPU number
Because obviously , The higher the percentage of thread waiting time , More threads needed . Threads CPU The higher the proportion of time , The fewer threads needed .
Here's an example :
For example, average per thread CPU Run at 0.5s, And thread waiting time ( Not CPU The elapsed time , such as IO) by 1.5s,CPU The core number is 8, So according to the above formula, it is estimated that :((0.5+1.5)/0.5)*8=32. This formula is further transformed into :
The best number of threads = ( Thread waiting time and thread CPU The ratio of time + 1)* CPU number
The empirical value of thread pool size just mentioned , It's actually an estimate of this formula .
版权声明
本文为[Think of the source after drinking water 09]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210627383681.html
边栏推荐
猜你喜欢

【WPF】利用Ellipse或Rectangle制作圆形进度条

Implementation of crud of user management system with JDBC

NP and OSPF default routes

论文阅读:Security Challenges in an Increasingly Tangled Web

Enterprise service bus -- Introduction to muleesb

链表(C语言)

中介者模式(3.28-4.3)

【C#】文件操作

ELK日志分析系统的原理与介绍

論文閱讀:Measuring the Impact of a Successful DDoS Attack on the Customer Behaviour of Managed DNS Servi
随机推荐
When deploying. Net core on Linux platform to access SQL Server 2008 R2, it prompts the connection timeout exception
2022.2.14-2.27 责任链模式
企业服务总线--MuleESB简介
NP, NSSA area
标准函数返回值iResult
论文阅读:Domain Name Encryption Is Not Enough: Privacy Leakage via IP-based Website Fingerprinting
论文阅读:Measuring the Global Recursive DNS Infrastructure: A View From the Edge
@Slf4j注解中 log 报错
DeprecationWarning: NewId() is deprecated
NP, OSPF virtual link
Define a standard class
Studio3t 过期激活办法/以及重新设置使用日期的脚本不可用解决办法/Studio 3T无限激活原创
栈(C语言)
策略模式(2.28-3.6)
c#生成中文金额并用语音读取出来的完整类
Using Wireshark to restore pcap data stream to picture file
Signals
TCP三次握手和四次挥手简介(2022.4.18-4.24)
关于数据治理平台中数据仓库ODS、DW和DM概念理解
Spawning Processes and Exec‘ing Processes