{"id":12108,"date":"2019-03-22T10:28:11","date_gmt":"2019-03-22T10:28:11","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=12108"},"modified":"2019-03-22T10:28:11","modified_gmt":"2019-03-22T10:28:11","slug":"understand-linux-load-averages-and-monitor-performance-of-linux","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/22\/understand-linux-load-averages-and-monitor-performance-of-linux\/","title":{"rendered":"Understand Linux Load Averages and Monitor Performance of Linux"},"content":{"rendered":"<p>In this article, we will explain one of the critical Linux system administration tasks \u2013 performance monitoring in regards to system\/CPU load and load averages.<\/p>\n<p>Before we move any further, let\u2019s understand these two important phrases in all Unix-like systems:<\/p>\n<ul>\n<li><strong>System load\/CPU Load<\/strong>\u00a0\u2013 is a measurement of CPU over or under-utilization in a Linux system; the number of processes which are being executed by the CPU or in waiting state.<\/li>\n<li><strong>Load average<\/strong>\u00a0\u2013 is the average system load calculated over a given period of time of 1, 5 and 15 minutes.<\/li>\n<\/ul>\n<p>In Linux, the load-average is technically believed to be a running average of processes in it\u2019s (kernel) execution queue tagged as running or uninterruptible.<\/p>\n<p><strong>Note that:<\/strong><\/p>\n<ul>\n<li>All if not most systems powered by Linux or other Unix-like systems will possibly show the load average values somewhere for a user.<\/li>\n<li>A downright idle Linux system may have a load average of zero, excluding the idle process.<\/li>\n<li>Nearly all Unix-like systems count only processes in the running or waiting states. But this is not the case with Linux, it includes processes in uninterruptible sleep states; those waiting for other system resources like disk I\/O etc.<\/li>\n<\/ul>\n<h3>How to Monitor Linux System Load Average<\/h3>\n<p>There are numerous ways of monitoring system load average including uptime which shows how long the system has been running, number of users together with load averages:<\/p>\n<pre><strong>$ uptime<\/strong>\r\n\r\n07:13:53 up 8 days, 19 min,  1 user,  load average: 1.98, 2.15, 2.21\r\n<\/pre>\n<p>The numbers are read from left to right, and the output above means that:<\/p>\n<ul>\n<li>load average over the last\u00a0<strong>1<\/strong>\u00a0minute is\u00a0<strong>1.98<\/strong><\/li>\n<li>load average over the last\u00a0<strong>5<\/strong>\u00a0minutes is\u00a0<strong>2.15<\/strong><\/li>\n<li>load average over the last\u00a0<strong>15<\/strong>\u00a0minutes is\u00a0<strong>2.21<\/strong><\/li>\n<\/ul>\n<p>High load averages imply that a system is overloaded; many processes are waiting for CPU time.<\/p>\n<p>We will uncover this in the next section in relation to number of CPU cores. Additionally, we can as well use other well known tools such as\u00a0<a href=\"https:\/\/www.tecmint.com\/12-top-command-examples-in-linux\/\" target=\"_blank\" rel=\"noopener noreferrer\">top<\/a>\u00a0and\u00a0<a href=\"https:\/\/www.tecmint.com\/glances-an-advanced-real-time-system-monitoring-tool-for-linux\/\" target=\"_blank\" rel=\"noopener noreferrer\">glances<\/a>\u00a0which display a real-time state of a running Linux system, plus many other tools:<\/p>\n<h4>Top Command<\/h4>\n<pre>$ top\r\n<\/pre>\n<div class=\"code-label\">Display Running Linux Processes<\/div>\n<pre>top - 12:51:42 up  2:11,  1 user,  load average: 1.22, 1.12, 1.26\r\nTasks: 243 total,   1 running, 242 sleeping,   0 stopped,   0 zombie\r\n%Cpu(s): 17.4 us,  2.9 sy,  0.3 ni, 74.8 id,  4.6 wa,  0.0 hi,  0.0 si,  0.0 st\r\nKiB Mem :  8069036 total,   388060 free,  4381184 used,  3299792 buff\/cache\r\nKiB Swap:  3906556 total,  3901876 free,     4680 used.  2807464 avail Mem \r\n\r\n  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                                                                        \r\n 6265 tecmint   20   0 1244348 170680  83616 S  13.3  2.1   6:47.72 Headset                                                                                                                                        \r\n 2301 tecmint    9 -11  640332  13344   9932 S   6.7  0.2   2:18.96 pulseaudio                                                                                                                                     \r\n 2459 tecmint   20   0 1707692 315628  62992 S   6.7  3.9   6:55.45 cinnamon                                                                                                                                       \r\n 2957 tecmint   20   0 2644644 1.035g 137968 S   6.7 13.5  50:11.13 firefox                                                                                                                                        \r\n 3208 tecmint   20   0  507060  52136  33152 S   6.7  0.6   0:04.34 gnome-terminal-                                                                                                                                \r\n 3272 tecmint   20   0 1521380 391324 178348 S   6.7  4.8   6:21.01 chrome                                                                                                                                         \r\n 6220 tecmint   20   0 1595392 106964  76836 S   6.7  1.3   3:31.94 Headset                                                                                                                                        \r\n    1 root      20   0  120056   6204   3964 S   0.0  0.1   0:01.83 systemd                                                                                                                                        \r\n    2 root      20   0       0      0      0 S   0.0  0.0   0:00.00 kthreadd                                                                                                                                       \r\n    3 root      20   0       0      0      0 S   0.0  0.0   0:00.10 ksoftirqd\/0                                                                                                                                    \r\n    5 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker\/0:0H   \r\n....\r\n<\/pre>\n<h4>Glances Tool<\/h4>\n<pre>$ glances\r\n<\/pre>\n<div class=\"code-label\">Glances \u2013 Linux System Monitoring Tool<\/div>\n<pre>TecMint (LinuxMint 18 64bit \/ Linux 4.4.0-21-generic)                                                                                                                                               Uptime: 2:16:06\r\n\r\nCPU      16.4%  nice:     0.1%                                        LOAD    4-core                                        MEM     60.5%  active:    4.90G                                        SWAP      0.1%\r\nuser:    10.2%  irq:      0.0%                                        1 min:    1.20                                        total:  7.70G  inactive:  2.07G                                        total:   3.73G\r\nsystem:   3.4%  iowait:   2.7%                                        5 min:    1.16                                        used:   4.66G  buffers:    242M                                        used:    4.57M\r\nidle:    83.6%  steal:    0.0%                                        15 min:   1.24                                        free:   3.04G  cached:    2.58G                                        free:    3.72G\r\n\r\nNETWORK     Rx\/s   Tx\/s   TASKS 253 (883 thr), 1 run, 252 slp, 0 oth sorted automatically by cpu_percent, flat view\r\nenp1s0     525Kb   31Kb\r\nlo           2Kb    2Kb     CPU%  MEM%  VIRT   RES   PID USER        NI S    TIME+ IOR\/s IOW\/s Command \r\nwlp2s0        0b     0b     14.6  13.3 2.53G 1.03G  2957 tecmint      0 S 51:49.10     0   40K \/usr\/lib\/firefox\/firefox \r\n                             7.4   2.2 1.16G  176M  6265 tecmint      0 S  7:08.18     0     0 \/usr\/lib\/Headset\/Headset --type=renderer --no-sandbox --primordial-pipe-token=879B36514C6BEDB183D3E4142774D1DF --lan\r\nDISK I\/O     R\/s    W\/s      4.9   3.9 1.63G  310M  2459 tecmint      0 R  7:12.18     0     0 cinnamon --replace\r\nram0           0      0      4.2   0.2  625M 13.0M  2301 tecmint    -11 S  2:29.72     0     0 \/usr\/bin\/pulseaudio --start --log-target=syslog\r\nram1           0      0      4.2   1.3 1.52G  105M  6220 tecmint      0 S  3:42.64     0     0 \/usr\/lib\/Headset\/Headset \r\nram10          0      0      2.9   0.8  409M 66.7M  6240 tecmint      0 S  2:40.44     0     0 \/usr\/lib\/Headset\/Headset --type=gpu-process --no-sandbox --supports-dual-gpus=false --gpu-driver-bug-workarounds=7,2\r\nram11          0      0      2.9   1.8  531M  142M  1690 root         0 S  6:03.79     0     0 \/usr\/lib\/xorg\/Xorg :0 -audit 0 -auth \/var\/lib\/mdm\/:0.Xauth -nolisten tcp vt8\r\nram12          0      0      2.6   0.3 79.3M 23.8M  9651 tecmint      0 R  0:00.71     0     0 \/usr\/bin\/python3 \/usr\/bin\/glances\r\nram13          0      0      1.6   4.8 1.45G  382M  3272 tecmint      0 S  6:25.30     0    4K \/opt\/google\/chrome\/chrome \r\n...\r\n<\/pre>\n<p>The load averages shown by these tools is read\u00a0<strong>\/proc\/loadavg<\/strong>\u00a0file, which you can view using the\u00a0<a href=\"https:\/\/www.tecmint.com\/13-basic-cat-command-examples-in-linux\/\" target=\"_blank\" rel=\"noopener noreferrer\">cat command<\/a>as below:<\/p>\n<pre><strong>$ cat \/proc\/loadavg<\/strong>\r\n\r\n2.48 1.69 1.42 5\/889 10570\r\n<\/pre>\n<p>To monitor load averages in graph format, check out:\u00a0<a href=\"https:\/\/www.tecmint.com\/ttyload-shows-color-coded-graph-of-linux-load-average\/\" target=\"_blank\" rel=\"noopener noreferrer\">ttyload \u2013 Shows a Color-coded Graph of Linux Load Average in Terminal<\/a><\/p>\n<p>On desktop machines, there are graphical user interface tools that we can use to view system load averages.<\/p>\n<h3>Understanding System Average Load in Relation Number of CPUs<\/h3>\n<p>We can\u2019t possibly explain system load or system performance without shedding light on the impact of the number of CPU cores on performance.<\/p>\n<h4>Multi-processor Vs Multi-core<\/h4>\n<ul>\n<li><strong>Multi-processor<\/strong>\u00a0\u2013 is where two or more physical CPU\u2019s are integrated into a single computer system.<\/li>\n<li><strong>Multi-core processor<\/strong>\u00a0\u2013 is a single physical CPU which has at least two or more separate cores (or what we can also refer to as processing units) that work in parallel. Meaning a dual-core has 2 two processing units, a quad-core has 4 processing units and so on.<\/li>\n<\/ul>\n<p>Furthermore, there is also a processor technology which was first introduced by Intel to improve parallel computing, referred to as hyper threading.<\/p>\n<p>Under hyper threading, a single physical CPU core appears as two logical CPUs core to an operating system (but in reality, there is one physical hardware component).<\/p>\n<p>Note that a single CPU core can only carry out one task at a time, thus technologies such as multiple CPUs\/processors, multi-core CPUs and hyper-threading were brought to life.<\/p>\n<p>With more than one CPU, several programs can be executed simultaneously. Present-day Intel CPUs use a combination of both multiple cores and hyper-threading technology.<\/p>\n<p>To find the number of processing units available on a system, we may use the\u00a0<a href=\"https:\/\/www.tecmint.com\/check-linux-cpu-information\/\" target=\"_blank\" rel=\"noopener noreferrer\">nproc or lscpu commands<\/a>\u00a0as follows:<\/p>\n<pre><strong>$ nproc<\/strong>\r\n4\r\n\r\nOR\r\n<strong>lscpu<\/strong>\r\n<\/pre>\n<p>Another way to find the number of processing units using\u00a0<a href=\"https:\/\/www.tecmint.com\/12-practical-examples-of-linux-grep-command\/\" target=\"_blank\" rel=\"noopener noreferrer\">grep command<\/a>\u00a0as shown.<\/p>\n<pre><strong>$ grep 'model name' \/proc\/cpuinfo | wc -l<\/strong>\r\n\r\n4\r\n<\/pre>\n<p>Now, to further understand system load, we will take a few assumptions. Let\u2019s say we have load averages below:<\/p>\n<pre>23:16:49 up  10:49,  5 user,  load average: 1.00, 0.40, 3.35\r\n<\/pre>\n<h6>On a single core system this would mean:<\/h6>\n<ul>\n<li>The CPU was fully (100%) utilized on average; 1 processes was running on the CPU (1.00) over the last 1 minute.<\/li>\n<li>The CPU was idle by 60% on average; no processes were waiting for CPU time (0.40) over the last 5 minutes.<\/li>\n<li>The CPU was overloaded by 235% on average; 2.35 processes were waiting for CPU time (3.35) over the last 15 minutes.<\/li>\n<\/ul>\n<h6>On a dual-core system this would mean:<\/h6>\n<ul>\n<li>The one CPU was 100% idle on average, one CPU was being used; no processes were waiting for CPU time(1.00) over the last 1 minute.<\/li>\n<li>The CPUs were idle by 160% on average; no processes were waiting for CPU time. (0.40) over the last 5 minutes.<\/li>\n<li>The CPUs were overloaded by 135% on average; 1.35 processes were waiting for CPU time. (3.35) over the last 15 minutes.<\/li>\n<\/ul>\n<p>You might also like:<\/p>\n<ol>\n<li><a href=\"https:\/\/www.tecmint.com\/command-line-tools-to-monitor-linux-performance\/\" target=\"_blank\" rel=\"noopener noreferrer\">20 Command Line Tools to Monitor Linux Performance \u2013 Part 1<\/a><\/li>\n<li><a href=\"https:\/\/www.tecmint.com\/linux-performance-monitoring-tools\/\" target=\"_blank\" rel=\"noopener noreferrer\">13 Linux Performance Monitoring Tools \u2013 Part 2<\/a><\/li>\n<li><a href=\"https:\/\/www.tecmint.com\/perf-performance-monitoring-and-analysis-tool-for-linux\/\" target=\"_blank\" rel=\"noopener noreferrer\">Perf- A Performance Monitoring and Analysis Tool for Linux<\/a><\/li>\n<li><a href=\"https:\/\/www.tecmint.com\/nmon-analyze-and-monitor-linux-system-performance\/\" target=\"_blank\" rel=\"noopener noreferrer\">Nmon: Analyze and Monitor Linux System Performance<\/a><\/li>\n<\/ol>\n<p>In conclusion, if you are a system administrator then high load averages are real to worry about. When they are high, above the number of CPU cores, it signifies high demand for the CPUs, and low load averages below the number of CPU cores tells us that CPUs are underutilized.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/understand-linux-load-averages-and-monitor-performance\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article, we will explain one of the critical Linux system administration tasks \u2013 performance monitoring in regards to system\/CPU load and load averages. Before we move any further, let\u2019s understand these two important phrases in all Unix-like systems: System load\/CPU Load\u00a0\u2013 is a measurement of CPU over or under-utilization in a Linux system; &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/22\/understand-linux-load-averages-and-monitor-performance-of-linux\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Understand Linux Load Averages and Monitor Performance of Linux&#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-12108","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\/12108","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=12108"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12108\/revisions"}],"predecessor-version":[{"id":12109,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12108\/revisions\/12109"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=12108"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=12108"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=12108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}