当前位置:网站首页>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!
↓ ↓ ↓ ↓
边栏推荐
- PHP代码审计9—代码执行漏洞
- Flask framework implementations registered encryption, a Flask enterprise class learning 】 【
- gbase8s创建RANGE分片表
- 合宙Cat1 4G模块Air724UG配置RNDIS网卡或PPP拨号,通过RNDIS网卡使开发板上网(以RV1126/1109开发板为例)
- flink-cdc支持并行读取一张mysql表的binlog不?
- Iptables防火墙基础知识介绍
- Flask框架实现注册加密功能详解【Flask企业课学习】
- mq消息积压怎么对应
- 通俗易懂-二维数组只能省略行不能省略列-人话版本
- 如何模拟后台API调用场景,很细!
猜你喜欢
随机推荐
【注册荣耀开发者】赢【荣耀70】手机
机器学习——线性回归
DHCP&OSPF combined experimental demonstration (Huawei routing and switching equipment configuration)
BigDecimal 使用注意!!“别踩坑”
Matlab drawing 1
Go language Go language, understand Go language file operation in one article
ATF中断处理的设计模型
静态iP与权限更改[通俗易懂]
Literature Review on Involution of College Students
实验室专利书写指南
EuROC 数据集格式及相关代码
buuctf(探险1)
作业8.3 线程同步互斥机制条件变量
离线同步odps到mysql 中文乱码是因为?mysql已是utf8mb4
asp dotnet core 通过图片统计 csdn 用户访问
PHP代码审计8—SSRF 漏洞
通配符SSL证书不支持多域名吗?
vantui 组件 van-field 路由切换时,字体样式混乱问题
火灾报警联网FC18中CAN光端机常见问题解答和使用指导
curl命令的那些事









