Daniel López Azaña

Theme

Social Media

Blog

Tag: CPU

What is the true meaning of system average load and CPU utilization in Linux?

| |
Carga del sistema y utilización de CPU en htop

The CPU average load value is a very important metric to understand the behavior of a Linux system, and especially its current and recent past status. Many times there is confusion between this term and percentage of CPU usage, but differences are important. In this article I will try to explain the true meaning of both and how to tell if a Linux box is overloaded or underutilized.

It is shown in the different monitoring tools (top, atop, htop, etc.) as a set of 3 values representing the average CPU load experienced by a Linux system in the last 1, 5 and 15 minutes respectively. Therefore, a first difference is that these are historical values, while the percentage of CPU usage is typically measured in intervals of between 1 and 5 seconds, so their value is usually almost instantaneous.

Differences between physical CPU vs logical CPU vs Core vs Thread vs Socket

| |
CPU ,HyperThreading
single-core-hyperthreading-cpu-diagram

When we try to know a computer’s architecture and performance at CPU level using Linux commands like nproc or lscpu, we often find out that we are not able to properly interpret their results because we confuse terms such as physical CPU, logical CPU, virtual CPU, core, thread, socket, etc. If we add concepts like HyperThreading (not to be confused with multithreading), we are in a situation where we can not be sure how many cores our box has, we don’t understand why commands like htop indicate that we have 8 cpus when we thought we had bought a single quad-core processor, etc. In short, it’s a mess.

High CPU load when converting images with ImageMagick

| |
CPU ,ImageMagick, PHP
Imagemagick-logo

In certain versions of ImageMagick there is a problem (probably due to a bug) when trying to convert or manipulate an image either from the command line (convert command) or through one of the many API’s available (for example PHP). The CPU usage suddenly grows beyond 100% (because this problem occurs on multiprocessor systems) and the system becomes extremely slow. Apart from this high CPU load, the conversion process also gets blocked, never reaching to the end. This occurs even with small images of few kilobytes.

How to know how many cores and processors has a Linux box

cpu-cores

The simplest and shortest method to measure the number of processors present on a Linux box, which is also widely extended as it’s part of coreutils is:

Another way to get the same result which also allows us to obtain additional information from our processor are the lscpu command:

Or we can examine the cpuinfo file from /proc filesystem:

There are many additional details about these processors in /proc/cpuinfo file, including the CPU model and number of cores: