C
C#5mo ago
SY

how to check what causes 100% cpu usages ?

I created a server in c# for some reason on my machine it doesn't use 100% of cpu but once I host it on a vps i see that it uses 100%
9 Replies
RD Dev
RD Dev5mo ago
Check server settings
Sossenbinder
Sossenbinder5mo ago
A good starting point is usually to check the dotnet cli tools
Sossenbinder
Sossenbinder5mo ago
https://learn.microsoft.com/en-us/dotnet/core/diagnostics/dotnet-counters for checking out some common counters like GC metrics etc.
dotnet-counters diagnostic tool - .NET CLI - .NET
Learn how to install and use the dotnet-counter CLI tool for ad-hoc health monitoring and first-level performance investigation.
Sossenbinder
Sossenbinder5mo ago
You can then follow up with https://learn.microsoft.com/en-us/dotnet/core/diagnostics/dotnet-trace to capture a trace
dotnet-trace diagnostic tool - .NET CLI - .NET
Learn how to install and use the dotnet-trace CLI tool to collect .NET traces of a running process without the native profiler, by using the .NET EventPipe.
Sossenbinder
Sossenbinder5mo ago
I usually like to analyze everything with dottrace, but VS also has decent support for trace analysis If you have a dottrace license you can also attach it to a remote client if you have that installed, but I think that only works properly with windows apps which barely anyone uses in net core land
Jimmacle
Jimmacle5mo ago
are you considering that the VPS probably has a weaker CPU than your machine? the CPU isn't a single unit either, there are multiple cores so depending on how your application is multithreaded you could be pegging 1 of 8 cores on your machine and 1 of 1 on the VPS
SY
SY5mo ago
yeah ofcourse its weaker but like I wanted to know if the mistake is from my server it self or like the vps cpu is weak and i need to upgrade it
Sossenbinder
Sossenbinder5mo ago
If you're on the cloud, honestly, just scale it up for an hour It will cost you a dollar maybe Investigating it for a few hours will cost you more
Lex Li
Lex Li5mo ago
It really depends on how much access you have on that VPS. With tools like performance profiler or WinDbg, learning the cause of high CPU is rather simple.