{"id":8219,"date":"2019-01-16T06:52:03","date_gmt":"2019-01-16T06:52:03","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw92\/?p=8219"},"modified":"2019-03-07T22:47:35","modified_gmt":"2019-03-07T22:47:35","slug":"understanding-load-average-on-linux-linux-hint","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/01\/16\/understanding-load-average-on-linux-linux-hint\/","title":{"rendered":"Understanding Load Average on Linux \u2013 Linux Hint"},"content":{"rendered":"<p>Load average is a measurement of the amount of work versus free CPU cycles available on a system processor. In this article I\u2019ll define the term, demonstrate how Linux calculates this value, then provide insight into how to interpret system load.<\/p>\n<p>Before we dive into Linux load averages, we must explore the different ways load is calculated and address the most common measurement of CPU load \u2013 a percentage.<\/p>\n<p>Windows calculates load differently from Linux, and since Windows has been historically more popular on the desktop, the Windows definition of load is generally understood by most computer users. Most Windows users have seen the system load in the task manager displayed as a percentage ranging from 0% to 100%.<\/p>\n<p>In Windows this is derived by examining how \u201cbusy\u201d the <em>System Idle Process<\/em> is and using the inverse to represent the system load. For example, if the idle thread is executing 99% of the time, CPU load in Windows would be 1%. This value is easy to understand but provides less overall detail about the true status of the system.<\/p>\n<p>In Linux, the load average is instead is represented by a decimal number starting at 0.00. The value can be roughly defined as the number of processes over the past minute that had to wait their turn for execution. Unlike Windows, Linux load average is not an instant measurement. Load is given in three values \u2013 the one minute average, the five minute average, and the fifteen minute average.<\/p>\n<h2>Understanding Load Average in Linux<\/h2>\n<p>At first, this extra layer of detail seems unnecessary if you simply want to know the current state of CPU load in your system. But since the averages of three time periods are given, rather than an instant measurement, you can get a more complete idea of the change of system load over time in a single glance of three numbers<\/p>\n<p>Displaying the load average is simple. On the command line, you can use a variety of commands. I simply use the \u201cw\u201d command:<\/p>\n<p>root@virgo [~]# w<br \/>\n21:08:43 up 38 days, 4:34, 4 users, load average: 3.11, 2.75, 2.70<\/p>\n<p>The rest of the command will display who\u2019s logged on and what they\u2019re executing, but for our purposes this information is irrelevant so I\u2019ve clipped it from the above display.<\/p>\n<p>In an ideal system, no process should be held up by another process (or thread), but <em>in a single processor system, <\/em>this occurs when the load goes above 1.00.<\/p>\n<p>The words \u201csingle processor system\u201d are incredibly important here. Unless you\u2019re running an ancient computer, your machine probably has multiple CPU cores. In the machine I\u2019m on, I have 16 cores:<\/p>\n<p>In this case, a load average of 3.11 is not alarming at all. It simply means that a bit more than three processes were ready to execute and CPU cores were present to handle their execution. On this particular system, the load would have to reach 16 to be considered at \u201c100%\u201d.<\/p>\n<p>To translate this to a percent-based system load, you could use this simple, if not obtuse, command:<\/p>\n<p>cat \/proc\/loadavg | cut -c 1-4 | echo &#8220;scale=2; ($(&lt;\/dev\/stdin)\/`nproc`)*100&#8221; | bc -l<\/p>\n<p>This command sequences isolates the 1-minute average via cut and echos it, divided by the number of CPU cores, through bc, a command-line calculator, to derive the percentage.<\/p>\n<p>This value is by no means scientific but does provide a rough approximation of CPU load in percent.<\/p>\n<h3>A Minute to Learn, a Lifetime to Master<\/h3>\n<p>In the previous section I put the \u201c100%\u201d example of a load of 16.0 on a 16 CPU core system in quotes because the calculation of load in Linux is a bit more nebulous than Windows. The system administrator must keep in mind that:<\/p>\n<ul>\n<li>Load is expressed in waiting processes and threads<\/li>\n<li>It is not an instantaneous value, rather an average, and<\/li>\n<li>It\u2019s interpretation must include the number of CPU cores, and<\/li>\n<li>May over-inflate I\/O waits like disk reads<\/li>\n<\/ul>\n<p>Because of this, getting a handle of CPU load on a Linux system is not entirely an empirical matter. Even if it were, CPU load alone is not an adequate measurement of overall system resource utilization. As such, an experienced Linux administrator will consider CPU load in concert with other values such as I\/O wait and the percentage of kernel versus system time.<\/p>\n<h3>I\/O Wait<\/h3>\n<p>I\/O wait is most easily seen via the \u201ctop\u201d command:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2019\/01\/1-27.png\" alt=\"\" width=\"1140\" height=\"179\" \/><\/p>\n<p>In the screenshot above I have highlighted the I\/O wait value. This is a percentage of time that the CPU was waiting on input or output commands to complete. This is usually indicative of high disk activity. While a high wait percentage alone may not significantly degrade CPU-bound tasks, it will reduce I\/O performance for other tasks and will make the system feel sluggish.<\/p>\n<p>High I\/O wait without any obvious cause might indicate a problem with a disk. Use the \u201cdmesg\u201d command to see if any errors have occurred.<\/p>\n<h3>Kernel vs. System Time<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2019\/01\/2-26.png\" alt=\"\" width=\"1140\" height=\"179\" \/><\/p>\n<p>The above highlighted values represent the user and kernel (system) time. This is a breakdown of the overall consumption of CPU time by users (i.e. applications, etc.) and the kernel (i.e. interaction with system devices). Higher user time will indicate more CPU usage by programs where higher kernel time will indicate more system-level processing.<\/p>\n<h2>A Fairly Average Load<\/h2>\n<p>Learning the relationship of load average to actual system performance takes time, but before long you\u2019ll see a distinct correlation. Armed with the intricacies of system performance metrics, you\u2019ll be able to make better decisions about hardware upgrades and program resource utilization.<\/p>\n<p><a href=\"https:\/\/linuxhint.com\/load_average_linux\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Load average is a measurement of the amount of work versus free CPU cycles available on a system processor. In this article I\u2019ll define the term, demonstrate how Linux calculates this value, then provide insight into how to interpret system load. Before we dive into Linux load averages, we must explore the different ways load &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/01\/16\/understanding-load-average-on-linux-linux-hint\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Understanding Load Average on Linux \u2013 Linux Hint&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-8219","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/8219","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=8219"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/8219\/revisions"}],"predecessor-version":[{"id":10632,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/8219\/revisions\/10632"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=8219"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=8219"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=8219"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}