A fundamental skill in managing a Linux system is understanding its performance. One of the most useful commands for a quick health check is uptime.
pete@icebox:~$ uptime
17:23:35 up 1 day, 5:59, 2 users, load average: 0.00, 0.02, 0.05
While we've seen uptime before, let's focus on the load average field, which is crucial for Linux CPU monitoring.
Understanding Load Average
The load average provides a snapshot of the CPU load on your system. The three numbers represent the average CPU load over the last 1, 5, and 15-minute intervals. But what is CPU load? It's the average number of processes in the run-queue, meaning they are either actively being executed by the CPU or are waiting for their turn. This metric is a key indicator of process utilization and overall system performance.
A Traffic Analogy
Imagine a single-core CPU as a single-lane highway.
- If the highway is at full capacity with a steady flow of cars, traffic is at 100%, which corresponds to a load average of 1.0.
- If a major traffic jam occurs, and cars are backed up twice the capacity of the highway, the load is 200%, or a load average of 2.0.
- If the highway is half-empty, the load is 0.5.
- Ideally, you want a low load average, like a highway at 2 AM with no traffic.
In this analogy, the cars are processes waiting to be handled by the CPU.
Interpreting Load Average on Modern Systems
A load average of 1.0 doesn't necessarily mean your system is struggling. Most modern computers have multi-core processors. If you have a quad-core (4-core) processor, a load average of 1.0 means only 25% of your total CPU capacity is being used. Each core acts as an additional lane on the highway.
To properly interpret the load average, you must consider the number of CPU cores. You can view the number of cores on your system with the command cat /proc/cpuinfo.
A general rule for good system performance is to keep your load average below the number of cores. If you find that your machine consistently has a load average higher than its core count, it could indicate a performance bottleneck, such as a runaway process or insufficient hardware resources.