Hostwinds Blog

Search results for:


CPU Load: What is it, and How to Read and Manage it Featured Image

CPU Load: What is it, and How to Read and Manage it

by: Hostwinds Team  /  June 28, 2024


A survey found that 68% of system crashes are due to high CPU load​ (Site24x7)​, highlighting why it's important to keep an eye on your machine, be it a web server or computer, and its resources.

Let's take a look at CPU load, what it is, what it does, how to monitor performance, and some best practices.

What is CPU Load

CPU load is a measure of the amount of processing work that a web server or computer's central processing unit (CPU) is handling at any given time. It typically indicates the number of processes that are either being executed by the CPU or waiting in line to be processed.

Processes are how your computer or web server handles and prioritizes tasks—whether it's serving a webpage or opening a word document. Every process requires a certain amount of CPU to execute.

CPU Load Metrics

CPU load is shown as an average over three time periods: 1 minute, 5 minutes, and 15 minutes. Here's what these numbers mean:

1-minute load average: The average number of processes ready to run in the last minute.

5-minute load average: Smooths out short-term fluctuations, showing the average load over the last 5 minutes.

15-minute load average: Provides a longer-term view, showing the average load over the last 15 minutes.

What is a Good CPU Load Average?

What constitutes a "good" CPU load average depends on several factors, including the number of CPU cores and the specific use case of the system.

On a single-core CPU, having a load average below 1.0 is good, as it means the CPU is not being overworked and should have enough capacity to handle sudden increases in workload. A load average of 1.0 means the CPU is fully utilized. If the load average exceeds 1.0, it indicates that some processes are waiting for CPU time, which could slow processing down.

For multi-core CPUs, you divide the load average by the number of cores. So, a load average of 4.0 on a quad-core CPU means the CPU is fully utilized.

Practical Load Thresholds Per CPU Core

Idle to Low Load:

  • 0.0 to 0.5 per core: Indicates the CPU is underutilized or idle most of the time.

Moderate Load:

  • 0.5 to 1.0 per core: Suggests the CPU is handling a moderate workload and performing optimally.

High Load:

  • 1.0 to 2.0 per core: Indicates the CPU is heavily loaded but still within manageable limits. Systems can still perform well, but there might be some slowdowns.

Overloaded:

  • Above 2.0 per core: Indicates the CPU is overloaded, leading to significant performance degradation. This often results in longer response times and potential system instability.

Monitoring CPU Load

You can monitor CPU load using commands and tools available on most operating systems. These provide real-time statistics and help you monitor your system's performance.

For Unix-like operating systems

'top' command: This command displays real-time information about the CPU load, memory usage, and running processes. It shows which processes are using the most CPU time, making it easier to identify resource-hungry applications. When you type 'top' in the command-line, you'll see an output like this:

top - 12:34:56 up  1:23,  1 user,  load average: 0.20, 0.25, 0.30
Tasks: 123 total,   1 running, 122 sleeping,   0 stopped,   0 zombie
%Cpu(s):  3.2 us,  1.0 sy,  0.0 ni, 95.5 id,  0.2 wa,  0.0 hi,  0.1 si,  0.0 st

The output will be a continuously updated list of system processes, sorted by CPU usage by default. It also displays the load averages and the percentage of CPU usage for each core.

'uptime' command: The 'uptime' command gives a quick summary of how long your system has been running and the average load over the past 1, 5, and 15 minutes. It's useful for a quick check of the system's load without diving into detailed process information. When you type 'uptime' in the terminal, you get an output like this:

10:34:52 up 5 days,  3:46,  3 users,  load average: 0.28, 0.18, 0.12

This output shows the current time, how long the system has been running, the number of active users, and the load averages.

'ps' command: This command lists running processes along with their CPU and memory usage. It helps you identify specific processes causing high CPU load. The 'ps' command has many options, but a common usage is to see the top CPU-consuming processes. Do do this, run the following command:

ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10

This command will:

  • Select all known processes ('eo')

  • Display each process CPU usage ('pcpu'),

  • Display process ID ('pid')

  • Display user ('user') that initiated the command

  • Show the specific command that initiated the process ('args')

  • Sorts the top 10 processes ('head -10')  by CPU usage in descending order ('sort -k 1 -r')

The output looks something like this:

%CPU   PID USER     COMMAND
20.0  1234 johndoe  /usr/bin/python3 script.py
15.5  2345 janedoe  /usr/bin/java -jar application.jar
10.2  3456 johndoe  /usr/bin/gcc -o program source.c
 8.0  4567 janedoe  /usr/bin/python3 another_script.py
 6.5  5678 root     /usr/sbin/apache2 -k start
 4.0  6789 nobody   /usr/bin/nginx -g daemon off;
 3.5  7890 johndoe  /usr/bin/perl script.pl
 2.5  8901 janedoe  /usr/bin/mysql -u root -p
 1.0  9012 root     /usr/bin/sshd -D
 0.5  9123 johndoe  /bin/bash

For Windows Systems

Windows does not natively support 'top' and 'ps' commands as Unix-like systems do. However, you can still check your CPU resources:

Task Manager: A user-friendly tool that doesn't require command-line knowledge, task manager is a graphical tool that provides an overview of CPU usage and shows detailed information about running applications and processes.

  • Press 'Ctrl+Shift+Esc' to access Task Manager

Once there, check out the "Performance" tab to see real-time CPU usage, or the "Processes" tab to see details of each running process.

Resource Monitor: This is a Windows command-line option that will display detailed insights on CPU usage and system resources.

  • Type 'resmon' in the Run dialog ('Win+R') and press ENTER.

Single-Core vs. Multi-Core Systems

A core is the part of the CPU that performs the actual operation (tasks), such as executing instructions from programs.

Single-Core CPU: In a single-core processor, the CPU can only handle one task at a time. It can context switch, which means it can switch between tasks rapidly to give the appearance of running multiple applications. However, a single-core CPU can quickly bog down with too many simultaneous tasks.

Multi-Core CPU: A multi-core processor contains two or more cores within a single CPU. Each core can independently execute its own tasks, which significantly enhances performance and allows for true multitasking.

CPU Load vs. CPU Utilization

Monitoring both CPU load and utilization helps in understanding how effectively the server is utilizing its processing capabilities.

CPU Load: Refers to the number of tasks waiting for CPU time. It's represented as load averages over different time periods (1-minute, 5-minute, and 15-minute averages). These averages provide insights into short-term and long-term workload trends. A high CPU load suggests that tasks are competing for processing resources, potentially leading to slower responsiveness and performance degradation.

CPU Utilization: Measures the percentage of time the CPU is actively processing tasks. High CPU utilization indicates that the CPU is actively executing instructions and processing data. However, high utilization alone doesn't necessarily imply an overloaded system if the tasks are efficiently managed.

Causes of High CPU Load

High CPU load can be caused by:

Intensive Computational Tasks: Running complex calculations or processing large data sets increases CPU load, like rendering videos or running simulations.

Too Many Tasks Running Simultaneously: Multiple applications or background processes running at the same time can cause high CPU load. For instance, running a web browser, a video editor, and a game simultaneously can strain the CPU.

Inefficient or Stuck Processes: Some processes might use more CPU time than necessary or get stuck in an endless loop, continuously consuming CPU resources. This often happens with poorly designed or buggy software.

Managing and Reducing CPU Load

Studies show that maintaining a CPU load below 70% can improve system lifespan by 30%​.  This means keeping your CPU load in check not only improves performance but also extends the life of your hardware.

Here are few methods for reduce high CPU load:

Terminate or Restart Problematic Processes: Identify and end tasks that consume too much CPU. For instance, if an application is causing high load, you can end the task or restart the application. The top command can help you spot these tasks.

Update Software and Drivers: Outdated software and drivers can lead to inefficient CPU usage. Keeping your system updated can help improve performance by fixing bugs and optimizing resource use.

Reinstall or Downgrade Problematic Applications: If an application consistently causes high CPU load, reinstalling it or using an older version might resolve the issue. Sometimes newer versions have bugs that cause high CPU usage.

Reboot Your Computer: Sometimes, a good old fashioned reboot can clear out processes that are causing high load and reset the system. This is a quick and easy way to resolve temporary issues.

Monitoring CPU load is an important metric to keep an eye on if you want to maintain your server's performance and stability. By understanding CPU load metrics, using appropriate tools, and performing regular check ups you can prevent overload and ensure your web server or computer runs smoothly.

Written by Hostwinds Team  /  June 28, 2024