当前位置:网站首页>The CPU suddenly soars and the system responds slowly, what is the cause?Is there any way to check?
The CPU suddenly soars and the system responds slowly, what is the cause?Is there any way to check?
2022-08-04 18:33:00 【Tom bomb architecture】
[Java Interview] Scenario interview questions CPU suddenly soars, system response is slow, how to troubleshoot
During the interview process, scenario-based questions make it easier to detect a developer's basic abilities.No, a small friend went to Ali for an interview, and he encountered the first question about "how to troubleshoot the system's slow response when the CPU is so high"?At the time, the boy didn't know where to start.
Today, I would like to share with you my solution.
CPU is the core computing resource of the entire computer. For an application process, the smallest execution unit of the CPU is a thread.There are two reasons for the high CPU:

1. Too many CPU context switches.
For the CPU, each CPU core can only run one thread at the same time. If there are multiple threads to be executed, the CPU can only execute different threads through context switching.Context switching requires two things

Save the execution state of the running thread
Let the waiting thread execute
These two processes require the CPU to execute kernel-related instructions to achieve state preservation. If more context switches are used, a large amount of CPU resources will be occupied, so that the CPU cannot execute the instructions in the user process, resulting in a decrease in the response speed.In Java, operations such as file IO, network IO, lock waiting, and thread blocking will cause thread blocking and trigger context switching.

2. Excessive consumption of CPU resources.

That is, a large number of threads are created in the program, or some threads have been occupying CPU resources and cannot be released, such as an infinite loop!After the CPU utilization is too high, the threads in the application cannot obtain the scheduling of the CPU, thus affecting the execution efficiency of the program!Since the CPU utilization is high due to these two problems, we can use the top command to find the process with high CPU utilization, and use Shift+H to find the thread with high CPU consumption in the process. There are two situations here..
The thread with high CPU utilization is always the same, indicating that there is a situation in the program that the thread occupies the CPU for a long time and has not been released. In this case, the Dump log of the thread is obtained directly through jstack, and the problem can be found after locating the thread log.code.
The thread IDs with high CPU utilization are constantly changing, indicating that too many threads are created. You need to select several thread IDs and check the thread dump log through jstack.In the end, it is possible that the result of the positioning is that the program is normal, but at the moment when the CPU is soaring, the user access volume is large, resulting in insufficient system resources.
The above is my understanding of the problem!From this point of view, the interviewer mainly examines practical ability and problem-solving ideas.If you haven't practiced it, but you know the cause of the phenomenon that causes the CPU to soar, and say your solution, it's no problem to pass the interview.
I am the literary Tom who was delayed by programming, follow me, the interview is no longer difficult!
Finally, I organized all the interview questions I shared in the past into a 10W word document, hoping to improve the pass rate of fans

Full interview materials and answers and PDF documents:
Scan the business card below to get it!
↓ ↓ ↓ ↓
边栏推荐
- 【填空题】130道面试填空题
- 入选爱分析·银行数字化厂商全景报告,网易数帆助力金融数字化场景落地
- Route lazy loading
- Babbitt | Metaverse daily must-read: Weibo animation will recruit all kinds of virtual idols around the world and provide support for them...
- 【web自动化测试】playwright安装失败怎么办
- 在表格数据集上训练变分自编码器 (VAE)示例
- PHP代码审计9—代码执行漏洞
- 测试工程师如何突破职业瓶颈?
- Literature Review on Involution of College Students
- ptables基本语法使用规则
猜你喜欢

解决错误:The package-lock.json file was created with an old version of npm

MMDetection 使用示例:从入门到出门

网页端IM即时通讯开发:短轮询、长轮询、SSE、WebSocket

EasyCVR调用云端录像API接口返回错误且无录像文件生成,是什么原因?

入选爱分析·银行数字化厂商全景报告,网易数帆助力金融数字化场景落地

基于 eBPF 的 Kubernetes 可观测实践

Flask framework implementations registered encryption, a Flask enterprise class learning 】 【

链表的经典入门LeetCode题目

方法的重写

PHP代码审计9—代码执行漏洞
随机推荐
解决错误:The package-lock.json file was created with an old version of npm
CPU突然飙高系统反应慢,是怎么导致的?有什么办法排查?
gbase8s创建RANGE分片表
margin 塌陷和重合的理解
数仓建模面试
合宙Cat1 4G模块Air724UG配置RNDIS网卡或PPP拨号,通过RNDIS网卡使开发板上网(以RV1126/1109开发板为例)
(ECCV-2022)GaitEdge:超越普通的端到端步态识别,提高实用性
FE01_OneHot-Scala应用
单行、多行文本超出显示省略号
How does the intelligent video surveillance platform EasyCVR use the interface to export iframe addresses in batches?
巴比特 | 元宇宙每日必读:微博动漫将招募全球各类虚拟偶像并为其提供扶持...
如何模拟后台API调用场景,很细!
curl命令的那些事
2019年海淀区青少年程序设计挑战活动小学组复赛试题详细答案
leetcode 14. 最长公共前缀
如何让 JS 代码不可断点
Thrift installation configuration
EasyCVR调用云端录像API接口返回错误且无录像文件生成,是什么原因?
入选爱分析·银行数字化厂商全景报告,网易数帆助力金融数字化场景落地
[Distributed Advanced] Let's fill in those pits in Redis distributed locks.