Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.Net Core Host process High CPU usage in Windows 2016 IIS in Asp.Net Core 2.2 Application

I have developed a website in Asp.Net Core 2.2 and hosted on Azure VM (Windows Server 2016 Data Center) in IIS.

I observed that when I access the website then after few requests, it's CPU usage goes to 100% and website does not respond. When I kill the process (.Net Core Host), then website works fine and then again process consume 100% CPU.

enter image description here

I searched a lot in this and found no solution. Many people are suffering with this and still struggling.

Did anyone encountered this problem and found the solution or any workaround? I am open to upgrade (core 3.0) or downgrade (2.0) for my application if it solves the problem.

Any help would be really appreciated.

Edit: After searching on this, i came to know this https://github.com/Microsoft/ApplicationInsights-aspnetcore/issues/690#issuecomment-399046332

That person downgraded the application core v2.1 which solves the high cpu usage problem.

like image 621
Jitendra Pancholi Avatar asked Dec 26 '18 06:12

Jitendra Pancholi


People also ask

How prevent CPU usage 100% because of worker process IIS?

Fix high CPU usage in the IIS worker process. To fix the high CPU usage, you will need to do two things: Eliminate the blockages causing poor performance under high CPU usage (making your workload more elastic). Reduce CPU usage of the application code, to avoid CPU overloads and be able to handle more traffic.

What is .NET Core host process?

Using in-process hosting, an ASP.NET Core app runs in the same process as its IIS worker process. In-process hosting provides improved performance over out-of-process hosting because requests aren't proxied over the loopback adapter, a network interface that returns outgoing network traffic back to the same machine.

What causes high CPU usage C#?

May be your application runs multiple threads. I have same issue that runs multiple threads and in each thread there is continuous update which makes the application usage from 50% to 100%.


2 Answers

Finally I fixed the problem by downgraded the framework from asp.net core v2.2 to asp.net core v2.0.0

Upper versions are not stable yet.

like image 191
Jitendra Pancholi Avatar answered Oct 23 '22 11:10

Jitendra Pancholi


In my case one instance of 'HttpClient' makes CPU usage high, When I changed the code and create new instance for each request CPU usage went down, because of 'HttpClient' disposing problem with more than one instance and a lot of request in my scenario 'HttpClient' was replaced by 'HttpWebRequest'

like image 1
user193679 Avatar answered Oct 23 '22 09:10

user193679