Skip to content

The asp.net core application loads the CPU even after a user requests are terminated. #3446

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
neyromant opened this issue Aug 22, 2018 · 24 comments
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
Milestone

Comments

@neyromant
Copy link

neyromant commented Aug 22, 2018

Hi,
My asp.net core application is builded on .net core 2.1 and launched under CentOS 7.4 (Outside the Docker container).
During the working day, this application has a high load. At night, when requests from clients stop, the application continues to use a lot of CPU. This stops only if I restart the application.

I searched for the blocking code manually and using Ben.BlockingDetector. (Question about this here: benaadams/Ben.BlockingDetector#9) But I did not find anything.

I collected and tried to analyze metrics using perfcollect

These metrics are taken at night, when there are no requests from clients, but the application uses 206% of the CPU (The machine has 4 cores):

image

image

My metrics are available here: (my application's name is current_app.anm)
https://drive.google.com/open?id=1SHTJqfWUMMOECcDUKnz37st1r4u_P4-j

Can anyone tell me what could be causing this problem?
Thank you in advance for any response.

@neyromant neyromant reopened this Aug 22, 2018
@Eilon
Copy link
Contributor

Eilon commented Aug 27, 2018

@sebastienros - thoughts?

@neyromant
Copy link
Author

neyromant commented Sep 19, 2018

I thought that it depends on bug in System.IO.Pipelines package like issue in Kestrel
But after connecting the package <PackageReference Include="System.IO.Pipelines" Version="4.5.1" /> to my project nothing has changed.

dotnet/announcements#83
aspnet/KestrelHttpServer#2694

@davidfowl
Copy link
Member

@neyromant Did you update to .net core 2.1.4?

@neyromant
Copy link
Author

@davidfowl Not yet, I just updated System.IO.Pipelines package.
My application is Self Contained Application and I do not use Microsoft.AspNetCore.App.
Maybe the problem is this?

@Eilon
Copy link
Contributor

Eilon commented Oct 1, 2018

@sebastienros any ideas on how to diagnose this?

@gzpbx
Copy link

gzpbx commented Oct 5, 2018

@neyromant The same problem with yours - even no any request the asp.net core application still load high CPU, aspnet/KestrelHttpServer#2937

@sebastienros
Copy link
Member

It could be the finalizer thread that is getting blocked. It would run even without any requests.

  • Are you using EntityFramework, and changing how it's tracing SQL?
  • Are you using HttpClient to request external services?

@davidfowl
Copy link
Member

Can you take a memory dump? That might help as you can look at the finalizer queue that way.

@neyromant
Copy link
Author

neyromant commented Oct 6, 2018

  • Are you using EntityFramework, and changing how it's tracing SQL?
  • Are you using HttpClient to request external services?

Yes

@neyromant
Copy link
Author

Can you take a memory dump? That might help as you can look at the finalizer queue that way.

Yes, of cource. My dump is here:
https://drive.google.com/file/d/1GPDSDktxOL_Cma61ZKSw3NH4gyhYnkr5/view?usp=sharing

@davidfowl
Copy link
Member

@neyromant
Copy link
Author

This is gcore dump:

# ulimit -c unlimited 
# sudo gcore -o dump1 <pid of my self contained app>

@davidfowl
Copy link
Member

Yep, I figured from the size 😄. This was collected on CentOS 7.4 yeah?

@neyromant
Copy link
Author

This was collected on CentOS 7.4 yeah?

Yep, it is CentOS 7.4

@davidfowl
Copy link
Member

I can't get this dump to load properly:

Try “readelf -a dump1.17928” and you will get some error messages:

readelf: Error: Reading 0x18c00 bytes extends past end of file for section headers
readelf: Error: Section headers are not available

@neyromant
Copy link
Author

I'm sorry. I will check or I will soon make a new dump.

@neyromant
Copy link
Author

@davidfowl, I am sorry for long answer.
I have uploaded corrected and checked dump here: https://drive.google.com/file/d/1ErM5in4N7ED620QWNHtW2abKFua1PtnN/view?usp=sharing

@mmikirtumov
Copy link

We have the same issue and we use HttpClient.
This problem occured when we update to .Net Core 2.1.4.
For HttpClient we created wrapper class, which is scoped and constructor have only one line of code
_httpClient = new HttpClient();
Do you have any idea what is the problem?

@poke
Copy link
Contributor

poke commented Oct 22, 2018

@mmikirtumov Please consider using the HttpClientFactory for that. It will automatically follow the best practices when working with a HttpClient.

@mmikirtumov
Copy link

Thank you Patrick. I know that this is good practice. I am trying to figure it out what is the problem currently in my production server. And can HttpClient cause this issue?

@neyromant
Copy link
Author

We are use the HttpClientFactory.

@vmayushan
Copy link

vmayushan commented Nov 27, 2018

We are use the HttpClientFactory.

@neyromant
Have you resolved your issue? We have the same problem and now we are using HttpClientFactory.

We took a trace, but it didn't help us.
image

@neyromant
Copy link
Author

@Vlad294 Unfortunately no

@analogrelay analogrelay added this to the Discussions milestone Jun 10, 2019
@ghost
Copy link

ghost commented Nov 12, 2020

Thank you for contacting us. Due to a lack of activity on this discussion issue we're closing it in an effort to keep our backlog clean. If you believe there is a concern related to the ASP.NET Core framework, which hasn't been addressed yet, please file a new issue.

This issue will be locked after 30 more days of inactivity. If you still wish to discuss this subject after then, please create a new issue!

@ghost ghost closed this as completed Nov 12, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 12, 2020
@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Aug 24, 2023
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
Projects
None yet
Development

No branches or pull requests

10 participants