当前位置:网站首页>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!
↓ ↓ ↓ ↓
边栏推荐
- Day018 继承
- VPC2187/8 电流模式 PWM 控制器 4-100VIN 超宽压启动、高度集成电源控制芯片推荐
- 解决错误:The package-lock.json file was created with an old version of npm
- 【填空题】130道面试填空题
- 如何进行自动化测试?
- Activity数据库字段说明
- Babbitt | Metaverse daily must-read: Weibo animation will recruit all kinds of virtual idols around the world and provide support for them...
- Scala104-Spark.sql的内置日期时间函数
- 【杰神说说】物联大师2.0版本预告
- 2022 May 1 Mathematical Modeling Question C Explanation
猜你喜欢

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

leetcode 13. 罗马数字转整数

Flink/Scala - Storing data with RedisSink

Documentary on Security Reinforcement of Network Range Monitoring System (1)—SSL/TLS Encrypted Transmission of Log Data

DOM Clobbering的原理及应用

阿里云技术专家秦隆:云上如何进行混沌工程?

How does the intelligent video surveillance platform EasyCVR use the interface to export iframe addresses in batches?

BigDecimal 使用注意!!“别踩坑”

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

A group of friends asked for help, but the needs that were not solved in a week were solved in 3 minutes?
随机推荐
CAN光纤转换器CAN光端机解决消防火灾报警
Babbitt | Metaverse daily must-read: Weibo animation will recruit all kinds of virtual idols around the world and provide support for them...
袋鼠云思枢:数驹DTengine,助力企业构建高效的流批一体数据湖计算平台
Scala104-Spark.sql的内置日期时间函数
Web端即时通讯技术:WebSocket、socket.io、SSE
阿里云技术专家秦隆:云上如何进行混沌工程?
PHP代码审计9—代码执行漏洞
【RTOS训练营】关于上课和答疑
静态iP与权限更改[通俗易懂]
使用.NET简单实现一个Redis的高性能克隆版(二)
Google Earth Engine APP——一键在线查看全球1984-至今年的影像同时加载一个影像分析
【简答题】月薪4k和月薪8k的区别就在这里
【STM32】STM32单片机总目录
网站设计师:Nicepage 4.15 Crack By Xacker
EasyCVR调用云端录像API接口返回错误且无录像文件生成,是什么原因?
Win10只读文件夹怎么删除
【web自动化测试】playwright安装失败怎么办
力扣学习---0804
Flask framework implementations registered encryption, a Flask enterprise class learning 】 【
leetcode/含有所有字符的最短字符串