3

I would like to automatically stop/start or recycle the app pool when it reaches 80% of CPU usage for a certain period of time.

I see that under app pool Advanced Settings, there is a CPU section and it has Limit (percent), Limit Action and Limit Interval (minutes) properties.

What happens when I set the following?

`Limit Action` to `KillW3wp`
`Limit (percent)` to 80%
`Limit Interval (minutes)` to 1.  

According to the documentation, the application pool is shut down for the duration of the reset interval. Does this mean that if the app pool has a momentary spike to 80% it is immediately killed and restarted in 1 minute?

What I would like to have happened is if the CPU is > 80% for a minute or longer, the app pool is killed and a new one is created immediately (basically overlapped recycle). Is that possible?

P.S. I did some research and testing and here is what I found - in case someone else needs these features.

If your process is over Limit (percent) for period of Limit Interval (minutes), IIS will send a shutdown signal. If your process doesn't respond to it and shutdown peacefully, IIS will wait for period indicated in Application Pool Advanced Settings: Process Model / Shutdown Time Limit (seconds) and then forcefully shut it down. There will typically be entries in the Event Viewer describing what it's doing.

Note that in my experience, the timings were extremely approximate. Sometimes IIS would carry out its actions down to the second. But mostly they were off by up to a minute.

AngryHacker
  • 2,877
  • 6
  • 32
  • 33
  • https://blog.lextudio.com/a-test-page-for-iis-cpu-throttling-8813f76c67d Use a test page and a few simple experiments you can better understand how that works. – Lex Li Sep 27 '19 at 04:45
  • @LexLi from my testing, `KillW3wp` setting doesn't work at all. I've set it to [20%](https://i.imgur.com/6aIKX94.png) and IIS does nothing when it goes over. The `Throttle` setting does seem to work, but that is not what I need. – AngryHacker Sep 27 '19 at 15:54
  • @LexLi Another note about this test page is that the CPU percentage only applies to a single CPU. So saying ?cpu=100 will results in 12% utilization on a 8 core machine. – AngryHacker Sep 27 '19 at 16:07
  • If you don't know how to modify that page to generate more loads, you might follow this post to use WCAT https://blogs.iis.net/shauneagan/cpu-throttling-iis-7-vs-iis-8 – Lex Li Sep 27 '19 at 16:29
  • @LexLi I do. The SO reference in your link provided the code. I've updated my answer with findings. Hopefully it will help the next person. – AngryHacker Sep 27 '19 at 16:58

0 Answers0