From time to time I encounter a website that is maxing out the server’s CPU. In previous versions of IIS, there were two basic options. One, you could do nothing. Or two, you could kill the worker process for a specified number of minutes.
Neither is a good option for a production website, ultimately causing administrators to scramble for a sandbox solution for the site (especially if there are other sites running on this same server) and developers to drop everything to help track down the offending code. A new feature in IIS 8 is the built-in ability to throttle the CPU for each application pool.
There are three options that you set to configure CPU throttling on the application pool in IIS 8. The first is the Limit. This value is in 1/1000th of a percent so setting this to 50% would require that you enter 50000 as the value. If you find the 1/1000 confusing, you can think of it as .001 or .1%. Multiplying 50,000 by either of those will give you 50%.
Setting the CPU Limit is great, but it won’t do anything if you leave it to the default of NoAction. The previous option of KillW3wp is still there, but you will notice there are two other options: Throttle and ThrottleUnderLoad.
Throttle is a very helpful setting. As you can see in the picture above, the CPU for the site went from 100% to a more bearable average of 50%. It didn’t take the site offline, and allows it to function in some capacity without affecting the entire server. You have effectively created a sandbox on the production server, buying some time to get the issue addressed.
So what about ThrottleUnderLoad? You will see the picture above looks much like the first picture that I published in this post, and essentially it is, but there is one difference. The server is much more responsive when I took this last screen shot. The application is allowed to use all of the CPU but only if nothing else on the server needs it. If anything else needs CPU, it will have priority first and foremost before the application will.
The last setting to be aware of is Limit Interval (minutes). This essentially sets the interval that IIS will use to test the CPU limits. If you set this to zero, the feature will be disabled.
One last note that I’d like to mention is that IIS 8 has a lot of great built-in help that explains most, if not all, of the features. While the information contained isn’t exhaustive, it certainly is enough to get you started in most cases. For the application pools, the basic information about each feature is conveniently located at the bottom of the Advances Settings window.
If any of you are curious about how I created the lab environment to simulate 100% CPU, I create an endless loop with a simple while loop.
Read the complete post here