In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
How to analyze the process of solving the problem that w3wp occupies too much CPU? in view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
Since the launch of the project, there has been a heart-wrenching problem, and a BUG that does not have the confidence to deal with it, that is, when the application is started, it may cause cpu to run 99% or persist at a value such as 50%. In this way, the pressure on the server is very great, and the server is often unable to remotely. This problem can only be solved by killing the corresponding w3wp process through PowerShell.
Why don't you have the confidence to deal with this problem?
The reason is very simple, this problem is intermittent, not easy to reproduce, there is only a certain possibility that the CPU will run full when the project starts.
All the reproducible BUG will not be too difficult to deal with, and this kind of non-reproducible BUG is the most troublesome, because it is invisible and difficult to trace.
How to deal with this problem?
1. At first, use the guessing method to find keywords such as while and lock in the project, which is tantamount to looking for a needle in a haystack, and lax modifications will lead to other more serious problems, and soon the plan was abandoned after a search.
two。 Later, I remember using WinDbg to solve the problem of computer blue screen, and wondered if it was possible to grab the dump of the corresponding w3wp process for analysis.
Use WinDbg to find clues
1. It is extremely easy to grab dump because the server is 2008R2.
two。 Use WinDbg
View thread information after load SOS.dll.
Found that there are 7 threads are more time-consuming, at this time I think that I also use 7 threads, at this time the heart is extremely excited.
Switch to thread 21, look at the stack information and find
There is a jam in Dictionary's Insert, so when you check the status of other threads that take a long time, it is nothing more than a jam here.
Is the Insert method in Dictionary really clogged?
Run it several times after writing down the following test code
It is found that there are times when cpu is very high and sometimes it is normal.
Then the problem becomes clear, and it becomes very easy to solve it. To find the GetRoutes code, this is how it was originally implemented.
BundleTable.Bundles maintains a static dictionary table internally, so the problem is looming. Lock this code.
Modified code
After observing for a period of time, the problem was indeed solved.
Why the Insert in Dictionary is blocked
I know that Dictionary is not a thread-safe type, but I thought that when Dictionary was accessed in a non-thread-safe way, the data would be messy and not blocked or deadlocked, but this question surprised me: why would a project in Add cause congestion?
After decompiling the source code of Dictionary, it is found that it is extraordinarily complex and has not been studied in detail, so the following paragraph describes that you have your own ideas to read, which may be wrong or right.
The above is where I think there is a problem. When one thread executes Initialize, the value of the buckets array is modified, and the second thread enters the Initialize method at the same time, then the value maintained by the first thread is destroyed, resulting in a dead loop in the algorithm, which can also explain why cpu is sometimes 50% and sometimes 99%.
How many threads are currently in this state, and the more threads that occur, the more cpu is consumed.
This is the answer to the problem of how to analyze the problem that w3wp takes up too much CPU to solve the problem. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.