Search code examples
c#.netservercrashiis-8

Kill W3WP when CPU spikes through IIS advanced CPU settings


We have a problem website in Production that has been causing intermittent CPU spikes. It is very hard to find at the moment. Until we find its root cause, we would like to use IIS CPU advance setting to recycle the website iis pool.

To test this, I created a simple web api with one endpoint in a development environment. This endpoint does nothing but simulates CPU spike which does the job.

Now I have configured CPU settings to

Limit: 70 => IIS8 so it is %, value must be between 0 ~ 100

Limit Action: KillW3wp

Limit interval: 1

I have restarted iis pool and the website, and then I called the endpoint I created above. I can see CPU above 90% constantly.

Questions;

  1. The above fake website is called "KillCPU", when I called KillCPU endpoint, shouldn't IIS Worker Process get created to handle the request? But I looked at Task Manager, it showed KillCPU.exe (which consumes CPU as planed)

  2. When CPU usage was above 70%, why didn't KillCPU.exe get kill? Not only the process still appears in task management but also when I looked at Event Viewer, I can't see any event logs.

Can anyone please help?

Regards


Solution

  • After my test, it turns out that the process will be killed, but there will be a delay in the task manager.

    killCPU.exe and w3wp.exe are not the same process, you need to distinguish them. IIS kills w3wp.exe, the application killCPU.exe you created will not be killed.

    I set limit to the lowest value of 1, and the application CPU occupancy rate is 12%. In the resource monitor, w3wp.exe is still running, but the application has returned a 503 error, and the application pool in IIS has been stopped. If you view the process information from the work process in IIS, it will show that w3wp.exe still exists but the status is stopped. enter image description here

    You can set limit to 1 and test again. If you still cannot kill w3wp.exe, there may be a problem with IIS. Please reinstall it.