当前位置:网站首页>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!
↓ ↓ ↓ ↓
边栏推荐
- GBase8s存储过程
- Short-term reliability and economic evaluation of resilient microgrids under incentive-based demand response programs (Matlab code implementation)
- 开篇-开启全新的.NET现代应用开发体验
- Scala105-Spark.sql中collect_list用法
- 阿里云国际版使用ROS搭建WordPress教程
- 测试工程师如何突破职业瓶颈?
- 2019年海淀区青少年程序设计挑战活动小学组复赛试题详细答案
- mq消息积压怎么对应
- 谷歌开源芯片 180 纳米制造工艺
- 【注册荣耀开发者】赢【荣耀70】手机
猜你喜欢
合宙Cat1 4G模块Air724UG配置RNDIS网卡或PPP拨号,通过RNDIS网卡使开发板上网(以RV1126/1109开发板为例)
EasyCVR如何通过接口调用设备录像的倍速回放?
机器学习——线性回归
Flask framework implementations registered encryption, a Flask enterprise class learning 】 【
PHP代码审计10—命令执行漏洞
部署LVS-DR群集
图解LeetCode——899. 有序队列(难度:困难)
数据库SqlServer迁移PostgreSql实践
2019 Haidian District Youth Programming Challenge Activity Elementary Group Rematch Test Questions Detailed Answers
关于使用腾讯云HiFlow场景连接器每天提醒签到打卡
随机推荐
【杰神说说】物联大师2.0版本预告
Google AppSheet: 无需编程构建零代码应用
asp dotnet core 通过图片统计 csdn 用户访问
自己经常使用的三种调试:Pycharm、Vscode、pdb调试
阿里云国际版使用ROS搭建WordPress教程
2018年南海区小学生程序设计竞赛详细答案
工业元宇宙对工业带来的改变
mood swings
浅谈web网站架构演变过程
当项目中自动格式化插件Prettier和ESLint冲突报错时如何解决
基于 eBPF 的 Kubernetes 可观测实践
flink-cdc支持并行读取一张mysql表的binlog不?
FE01_OneHot-Scala应用
袋鼠云思枢:数驹DTengine,助力企业构建高效的流批一体数据湖计算平台
Flask framework implementations registered encryption, a Flask enterprise class learning 】 【
EasyCVR本地接入国标设备映射公网后,本地设备出现无法播放与级联的解决方法
PHP代码审计9—代码执行漏洞
防火墙基础之防火墙做出口设备安全防护
Develop those things: How to obtain the traffic statistics of the monitoring site through the EasyCVR platform?
2019 Haidian District Youth Programming Challenge Activity Elementary Group Rematch Test Questions Detailed Answers