Windows 10/Server High CPU Utilization Issue | Practical Steps

Windows 10
cpu utilization high
Windows Server Performance
how to fix high cpu usage
Windows Performance Counters

Introduction:

Hi There

      Today we will discuss performance analysis OR high CPU utilization issue on a Windows 10 system. The high CPU utilization/usage issue is not only limited to Windows 10 only but also can be seen in other client and server operating systems as well.

Windows Server Performance is a key factor for a system admin, hence I have focused to address few issues such as windows server performance, CPU high utilization, etc.

I haven’t tested the process across all operating systems however I am expecting it to work on client OS like Windows 7, Windows 10 & server OS like 2008 r2, Server 2012 r2, Server 2016, Server 2019.

Before I proceed let me explain the issue details so that we can understand what we are doing and how the performance report is analyzed.

Windows Performance – Issue Description:

  You are working in a company as a system administrator and one day you got an Incident from a user saying one of his applications server’s  CPU utilization getting high intermittently throughout the day (sporadic issue)   and he is not able identify what is causing these random CPU spikes.

               Such issues can’t be resolved immediately as we don’t know next time when the CPU spike will shoot up so that we could see in Task Manager what component/process is going high.

                In this case, we will use OS performance counters to start the capture of all the relevant details, wait for the next CPU spike and then stop the performance counter log collection to analyze the output log file.

                I hope we are clear on the steps that we are going to perform. So let’s jump in and log in to the system where the high CPU utilization issue is reported. here I am working on a Windows 10 system.

Simulating the Problem:

Before we start troubleshooting the issue lets create the issue first. To do that first of all we will download a small tool called cpustress.exe which will be used to simulate the issue.

Click the following link and download the cpustress.exe tool.

https://docs.microsoft.com/en-us/sysinternals/downloads/cpustres

The downloaded folder contains following file

Now from your system, open Task Manager and check what is the current CPU utilization. In my machine the current CPU utilization is as shown below. 28%

   Now we will start the log capture and then start the cpustress tool to shoot up the CPU utilization.

At this point we don’t know when the next CPU spike will happen , hence we are starting the log capture and leaving it for some hours. If you have a monitoring system in place then you will get the alert of CPU high utilization.

Use the following command to start the log capture.

logman.exe create counter High-CPU-Log -f bincirc -v mmddhhmm -max 250 -c "\LogicalDisk(*)\*" "\Memory\*" "\Network Interface(*)\*" "\Paging File(*)\*" "\PhysicalDisk(*)\*" "\Process(*)\*" "\Redirector\*" "\Server\*" "\System\*" "\Thread(*)\*"   -si 00:00:05

In this example, we have a capture interval of five seconds, with a Maximum Log size of 250MB.  The Performance Counters that we are capturing are fairly generic.

Default output location is C:\PerfLogs\your_user_name\

Open command prompt in admin mode and run the command

 

Run the following command to check the Data Collector Set is created.

    # logman query

Now start the Data Collector Set “High-CPU-Log”

# Logman start “High-CPU-Log”

If you run logman query again then can see the capture is started

Ok fine! The capture has been started. Now we will run cpustress tool to increase the CPU utilization upto ~95 %.

Go to the cpustress folder that you have downloaded and ron the CPUSTRES.EXE with Run As Administrator.

You will see following screen

Let’s activate more thread and increase the priority as shown below.

You can see in Task Manager that CPU utilization shoot up to 100%

Now close the cpustress windows and the CPU utilization will now come down as shown below.

Great! We have successfully simulated the high CPU utilization issue. In a real environment you may not know when and by what process the high utilization happened.

Now let’s stop the log capturing by running following command

Log Analysis:

The log has been captured and saved in the following location.

To do the log analysis we will download/clone following Powershell script from a github repo.

https://github.com/Jagat45106/SysAdmin_PSTools/tree/master/exPerfAnalyser

File Name: ExPerfAnalyzer.ps1

Open PowerShell Windows, go to folder location and run following command to get the analysis report

After the command execution is completed, a text file will get generated having the analysis result. See below

Open the above text file and go to the Process section, you can see the cpustress max utilization status. Which tells us for some time this is the process that shoots up to 235.3%

In real life you may see a different Microsoft/non-Microsoft process.

You can have a thorough look at the report and google to have more in depth knowledge related to performance counter, log analysis etc.

You may ask me how come it hit more than 200% utilization. So this depends on how many CPU cores you have and a mathematical calculation. Please go through below link to have a broader understanding

https://social.technet.microsoft.com/wiki/contents/articles/12984.understanding-processor-processor-time-and-process-processor-time.aspx

More details on LOGMAN.EXE can be found in below link

https://techcommunity.microsoft.com/t5/ask-the-performance-team/two-minute-drill-logman-exe/ba-p/373061

For my other PowerShell related blog post please visit following link

https://learn-inside.com/powershell/

That’s it for today! See you in my next blog!!! Stay Safe..

Please do share if  you liked it.