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 determine which threads run out of CPU through top and jstack

2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article is about how to use top and jstack to determine which threads run out of CPU, the editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article.

Background

The online cluster load will suddenly soar, with a CPU utilization rate of 100%, unable to respond to normal requests, and then the server goes down.

So what on earth is the thread that caused load to soar? Which threads dominate CPU? Positioning can be done through the top and jstack commands.

Positioning step

1. Top finds out the process PID that takes up high CPU.

2. The top-p PID-H command finds out which thread takes up the highest CPU in the process.

3. According to the thread ID (which needs to be converted from decimal to hexadecimal), find the thread found in step 2 from the thread stack

Printf 0x%x 43845

4. The jstack-l PID command prints out the thread stack

It is found that a large number of GC threads are running.

Why GC threads?

The final positioning problem is to call the database query method List queryForList (Query query) to pull a large number of data sets and load them into memory, all of which are small data. Small data was first loaded into the younger generation by JVM, but the memory of the younger generation soon filled up. JVM carried out yongGC, and the data was transferred to the old age, but in the old era, memory was also quickly filled up, and JVM carried out full GC, resulting in an avalanche with a memory occupancy rate of 100%.

The above is how to determine which threads run out of CPU through top and jstack. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

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

Internet Technology

Wechat

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

12
Report