Load Average: An Indicator for Only CPU Demand?
Not just for CPU, but I/O demand, too!
Join the DZone community and get the full member experience.Join For Free
‘Load Average‘ is an age-old metric reported in various operating systems. It’s often assumed as a metric to indicate the CPU demand only. However, that is not the case. ‘Load Average’ not only indicates CPU demand, but also the I/O demand (i.e., network read/write, file read/write, disk read/write). To prove this theory, we conducted this simple case study.
Load Average Study
To validate this theory, we leveraged BuggyApp. BuggyApp is an open-source Java project that can simulate various performance problems. When you launch BuggyApp with the following arguments, it will cause high disk I/O operations on the host.
Let’s see the source code in the BuggyApp, which is causing this high disk I/O activity.
Here you can see that BuggyApp is launching 5 ‘IOThreads’ in the ‘IODemo’ class. You can see that ‘IOThread’ is going on an infinite while loop. In the loop, the thread is writing the content into a file and reading the same content. It is doing these 2 steps repeatedly again and again. Writing content and reading content from the disk is an I/O intensive operation.
Load Average in Linux
When we ran this BuggyApp program in an AWS EC2 Amazon Linux 4.9.58 instance, below is the ‘top’ command output on this host:
Fig: Top output in Linux
You can see the Load Average is ‘5.0’. This AWS EC2 instance has just 1 CPU. Since it’s 1 CPU, the load on this system instance is 500%. If you aren’t sure how to read the Load Average, you can refer to this article. However, you can see that the overall system’s CPU consumption is only 2.1% (i.e., 1.4% user CPU utilization + 0.7% system CPU utilization) as highlighted in the above top output. Thus, even though the CPU demand is much less, the Load Average is very high. It clearly indicates that the Load Average is not just an indicator of CPU demand. It indicates the I/O demand on the system as well.
Opinions expressed by DZone contributors are their own.