Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to troubleshoot the problem that the system response is slow due to the high occupation of CPU by Java applications

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains "how to troubleshoot the problem that Java applications occupy high CPU and lead to slow system response". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to troubleshoot the problem that Java applications occupy high CPU and lead to slow system response".

1. Problem phenomenon

Feedback from a project team: the request response in the application production environment is actually long, and the client request timeout often occurs, and the system is almost unavailable.

2. Troubleshooting process 2.1. Check the resource usage of each server

By executing the top command in the database server and the application server, it is found that the java process of the application server occupies a high amount of CPU. Normally, when there is no traffic, the CPU utilization of the application server should be less than 1%, but the CPU utilization is about 20% to 30% at that time. (this is a picture made up afterwards.)

Records occupy the process number (pid) with a higher CPU.

2.2. Check the thread number that takes up a high CPU.

Execute top-H-p to see which threads account for a higher percentage of the total CPU.

Execute the command printf "% x\ n" (the thread number obtained by top-H-p when pid here, such as 5800, 5772, and so on in the figure above) to convert the decimal thread number to hexadecimal.

2.3. Dump the thread information in the process to a file

Execute jstack-l > threadinfo.txt (here the alive process id in the top command when pid) dumps the thread information into the file threadinfo.txt file using the command line jstack that comes with JDK. Then in the file, look for the executor corresponding to the hexadecimal thread number:

Java.util.concurrent.LinkedBlockingQueue.remove () method

Through Baidu (google), is a low-level version of JDK1.8 Bug. After upgrading the build environment JDK to 1.8 _ 238, the problem was resolved.

2.3.View the top 20-bit objects in memory to execute the command jmap-histo (here the process number obtained by the top command when pid is higher in CPU) | head-n 202.4, generate the dump file and execute the command jmap-dump:file=/tmp/javaDump.hprof,format=b (here the process number with higher CPU occupancy located by the top command when pid) Thank you for your reading The above is the content of "how to troubleshoot the problem that Java applications occupy high CPU and lead to slow system response". After the study of this article, I believe you have a deeper understanding of how to troubleshoot the problem that Java applications occupy high CPU and lead to slow system response, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report