I just started exploring .NET Core Web App development this year and am still trying to understand a lot of things.
I'm currently testing the .NET Core Web App on IIS. An Application Pool with default settings has been assigned to it. Everything seems to be working as expected. Then, I execute a heavy process, in which the CPU usage of the IIS Worker Process will jump to 100% during execution, as monitored with the Task Manager. While it's executing, there are difficulties browsing the web app. Any requests sent have very slow responses.
The process
The process completely follows this sample How to: Write a simple Parallel.ForEach loop. It is executed by calling its API Controller. For our testing, it took 10 minutes to complete its execution. Therefore, the web app will be slow during that 10 minutes. If it helps to know, the server has 16 logical processors, which during execution, all of its jumped to 100%. CPU usage of the IIS Worker Process will then drop after execution finished. Below is the process' method.
private List<ModelX> CalculationProcess(IList<ModelY> data)
{
var modelXs = new ConcurrentBag<ModelX>();
Parallel.ForEach(data, datum =>
{
try
{
modelXs.Add(datum.GenerateModelX());
}
catch (Exception)
{
// ...
}
});
return modelXs.ToList();
}
What has been done
I was under the assumption that it was just a matter of finding the right settings for the assigned Application Pool. So, I tested various settings, such as:
CPU Limit
to80
;CPU Action
toKillW3wp
,Throttle
, andThrottleUnderLoad
;Processor Affinity Enabled
totrue
;Maximum Worker Processes
to2
.
While CPU usage of the IIS Worker Process did get limit to around 80%, the web app was still slow when the process is executing. I haven't tested setting the limit lower than 80%, and I'm unsure if it makes any real difference. I no longer know what other options to try.
How can I prevent the web app from becoming slow when a certain heavy process is executing on the back-end? I'm fairly new to both .NET Core Web App development and IIS.