0

Im running a ASP.NET website on Windows 2008 and IIS7.

From time to time my w3wp.exe start spiking into 100% CPU, and the website hangs. I have not found the reason for this, but that is irrelevant at the moment. All I want is to configure the application pool to kill the w3wp.exe process when it is working on 100% CPU over a short period of time. How can I do this?

These are my application pool CPU settings: enter image description here

Also, if I kill the process, will the process be running as normal upon next request to the website, or do I have to start the process manually after it is killed?

Martin at Mennt
  • 177
  • 1
  • 2
  • 11
  • See [**How prevent CPU usage 100% because of worker process in IIS**](https://stackoverflow.com/a/31797857/1366033) – KyleMit Dec 04 '18 at 16:25

1 Answers1

6

The strict answer to your question is to set the limit to 1000*CPUPercent that you want to be the hard upper limit, and set the Action to KillW3WP. For example, to limit it at 90%, you would set the limit to 90000

More info on CPU limits in an application pool can be found here: http://www.iis.net/ConfigReference/system.applicationHost/applicationPools/add/cpu

I must say, however, you're trying to cure the symptom and not the problem. Debugging the code to figure out why this is happening will fix this for good, but killing the process is just sticking a temporary band-aid over it.

Hyppy
  • 15,608
  • 1
  • 38
  • 59
  • Thank you, and yes I know that I have to debug my code to solve the real problem :) – Martin at Mennt Mar 23 '11 at 12:36
  • +1 for the focused answer and the complete solution suggestion – Pitto Mar 23 '11 at 15:31
  • +1 for a great answer. Do you know if there's any way to trigger an email when KillW3wp occurs; or do you know the eventlog id of such an event (i.e. so I can use the windows scheduler to trigger a mail on seeing such an event)? I ask as whilst I like the app fixing the issue itself, having our team alerted will help us to find the underlying cause, and also to ensure we don't have phantom fixes occurring. – JohnLBevan Feb 04 '15 at 16:49
  • (ps. also posted my follow-up question here: http://serverfault.com/questions/665003/trigger-email-alert-on-killw3wp-event) – JohnLBevan Feb 04 '15 at 16:56
  • Does the process run again as normal upon next request to the website, or do I have to start the process manually afterwards? – Brett Larson Aug 17 '17 at 18:07
  • Did you get answer to this? Does the process run again as normal upon next request to the website, or do I have to start the process manually afterwards? – Krunal Apr 23 '19 at 06:54