{"id":71,"date":"2021-09-02T10:15:00","date_gmt":"2021-09-02T10:15:00","guid":{"rendered":"https:\/\/bestdedicatedhosting.in\/blog\/?p=71"},"modified":"2021-11-02T13:12:48","modified_gmt":"2021-11-02T13:12:48","slug":"understand-linux-load-averages-and-monitor-performance-of-linux","status":"publish","type":"post","link":"https:\/\/bestdedicatedhosting.in\/blog\/understand-linux-load-averages-and-monitor-performance-of-linux\/","title":{"rendered":"Understand Linux Load Averages and Monitor Performance of Linux"},"content":{"rendered":"\n<hr class=\"wp-block-separator\" id=\"block-4fd3a9e0-3264-4eaf-8710-3cd91883221c\"\/>\n\n\n\n<p id=\"block-56ddf814-8106-4355-9c07-cd51a9d60a53\"><strong>Description<\/strong><\/p>\n\n\n\n<p id=\"block-9887c75e-438b-465d-af4f-335f1c65fccf\">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\n\n\n<p id=\"block-bb120b64-3f05-4bc1-a470-a5299f4e9dea\">Before we move any further, let\u2019s understand these two important phrases in all Unix-like systems:<\/p>\n\n\n\n<ul class=\"wp-block-list\" id=\"block-2ce641f9-cf2e-4be6-a61a-2052ed09eeda\"><li><strong>System load\/CPU Load<\/strong>&nbsp;\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><li><strong>Load average<\/strong>&nbsp;\u2013 is the average system load calculated over a given period of time of 1, 5 and 15 minutes.<\/li><\/ul>\n\n\n\n<p id=\"block-0c677610-02f0-48fa-8137-a4f18fda7bda\">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\n\n\n<p id=\"block-0ad283ca-5b6f-47a4-8afa-1b664e8ae361\"><strong>Note that:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\" id=\"block-a082ea26-0a4d-4182-b422-14e63949728f\"><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><li>A downright idle Linux system may have a load average of zero, excluding the idle process.<\/li><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><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"block-aa923599-b88b-4a90-95e7-b2e8dccb85a9\">How to Monitor Linux System Load Average<\/h3>\n\n\n\n<p id=\"block-a62bd613-ab9d-4ca7-baa5-52995f5c7c12\">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\n\n\n<pre id=\"block-681c834d-6b32-4913-9894-14a2da11c642\" class=\"wp-block-code\"><code>$ uptime<br><br>07:13:53 up 8 days, 19 min,  1 user,  load average: 1.98, 2.15, 2.21<\/code><\/pre>\n\n\n\n<p id=\"block-7be28bf4-58b0-4548-8f24-eb787c099265\">The numbers are read from left to right, and the output above means that:<\/p>\n\n\n\n<ul class=\"wp-block-list\" id=\"block-b93ef03a-be70-476e-8f57-84f3686df993\"><li>load average over the last&nbsp;<strong>1<\/strong>&nbsp;minute is&nbsp;<strong>1.98<\/strong><\/li><li>load average over the last&nbsp;<strong>5<\/strong>&nbsp;minutes is&nbsp;<strong>2.15<\/strong><\/li><li>load average over the last&nbsp;<strong>15<\/strong>&nbsp;minutes is&nbsp;<strong>2.21<\/strong><\/li><\/ul>\n\n\n\n<p id=\"block-9ec5c1e7-2727-4ae0-905d-42c1ac47e070\">High load averages imply that a system is overloaded; many processes are waiting for CPU time.<\/p>\n\n\n\n<p id=\"block-80471d8f-422b-4090-9920-13407b578aa0\">We will uncover this in the next section in relation to number of CPU cores.<\/p>\n\n\n\n<p id=\"block-5ef50849-2359-4b20-b6aa-3c119d5779f9\">Additionally, we can as well use other well known tools such as&nbsp;top&nbsp;and&nbsp;glances&nbsp;which display a real-time state of a running Linux system, plus many other tools:<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"block-60550e2d-e68e-4ab8-8f2c-6b1baed8e083\">Top Command<\/h4>\n\n\n\n<pre id=\"block-bf1e9e45-3102-40b5-b4b7-07c501e5bd04\" class=\"wp-block-code\"><code>$ top<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"block-e12b1824-11be-4b6b-9756-ee65c0b6b0af\">Glances Tool<\/h4>\n\n\n\n<pre id=\"block-13d3f7c9-f739-4f7e-9b5f-5a9c457a69d1\" class=\"wp-block-code\"><code>$ glances<\/code><\/pre>\n\n\n\n<p id=\"block-4bf48081-cf52-4731-880d-c9a88de72c41\">The load averages shown by these tools is read&nbsp;<strong>\/proc\/loadavg<\/strong>&nbsp;file, which you can view using the&nbsp;<a href=\"http:\/\/jaipurhosting.com\/blog\/basic-cat-commands-in-linux-with-examples\/\" rel=\"nofollow noopener\" target=\"_blank\">cat command<\/a>&nbsp;as below:<\/p>\n\n\n\n<pre id=\"block-a31b799d-b6da-4162-8268-638363c0f5a3\" class=\"wp-block-code\"><code>$ cat \/proc\/loadavg<br><br>2.48 1.69 1.42 5\/889 10570<\/code><\/pre>\n\n\n\n<p id=\"block-aeaa4692-12d2-4ca7-af5b-d7eaa0304bd3\">To monitor load averages in graph format, check out:&nbsp;<a href=\"http:\/\/jaipurhosting.com\/blog\/ttyload-shows-a-color-coded-graph-of-linux-load-average-in-terminal\/\" rel=\"nofollow noopener\" target=\"_blank\">ttyload \u2013 Shows a Color-coded Graph of Linux Load Average in Terminal<\/a><\/p>\n\n\n\n<p id=\"block-2fd0962d-21dc-4d45-bd7b-ad42cb78ca90\">On desktop machines, there are graphical user interface tools that we can use to view system load averages<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"block-2ede0788-e615-4d61-bc99-db9fa7b406a5\">Understanding System Average Load in Relation Number of CPUs<\/h3>\n\n\n\n<p id=\"block-77933418-8852-4433-852b-e106503a43ab\">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\n\n\n<p id=\"block-19f27f47-408f-4d95-83c7-8ad15f795fd8\"><strong>Multi-processor Vs Multi-core<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\" id=\"block-5b88ccb4-0efa-448d-a819-cb2c1e4f582d\"><li><strong>Multi-processor<\/strong>&nbsp;\u2013 is where two or more physical CPU\u2019s are integrated into a single computer system.<\/li><li><strong>Multi-core processor<\/strong>&nbsp;\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><\/ul>\n\n\n\n<p id=\"block-3626123d-248a-4115-8df8-229eecd43c7c\">Furthermore, there is also a processor technology which was first introduced by Intel to improve parallel computing, referred to as hyper threading.<\/p>\n\n\n\n<p id=\"block-b43b1397-571e-49cf-b53b-ddc932b63530\">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\n\n\n<p id=\"block-10862f28-9db6-4adb-9499-b088cbbce268\">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\n\n\n<p id=\"block-45288b7f-f712-4d28-9f03-b90bdb08b0db\">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\n\n\n<p id=\"block-0cdcec6b-fd8f-455d-ba02-e59e394d436e\">To find the number of processing units available on a system, we may use the&nbsp;nproc or lscpu commands&nbsp;as follows:<\/p>\n\n\n\n<pre id=\"block-5dbfc723-5f84-4a72-8631-1a90d87ff29d\" class=\"wp-block-code\"><code>$ nproc<br>4<br><br>OR<br>lscpu<\/code><\/pre>\n\n\n\n<p id=\"block-147860d6-a4a9-42b4-a297-200c42501236\">Another way to find the number of processing units using&nbsp;<a href=\"http:\/\/jaipurhosting.com\/blog\/linux-grep-command-examples\/\" rel=\"nofollow noopener\" target=\"_blank\">grep command<\/a>&nbsp;as shown.<\/p>\n\n\n\n<pre id=\"block-eab67e0b-94eb-431f-9e01-5eecb440fbe5\" class=\"wp-block-code\"><code>$ grep 'model name' \/proc\/cpuinfo | wc -l<br><br>4<\/code><\/pre>\n\n\n\n<p id=\"block-cdc69046-29a4-4f1b-b273-5dbc386b9476\">Now, to further understand system load, we will take a few assumptions. Let\u2019s say we have load averages below:<\/p>\n\n\n\n<pre id=\"block-9bc2af70-620f-489d-ae8f-1661f17f7316\" class=\"wp-block-code\"><code>23:16:49 up  10:49,  5 user,  load average: 1.00, 0.40, 3.35<\/code><\/pre>\n\n\n\n<p id=\"block-ab71ef3d-6885-4eca-aab5-049d15bb3dba\"><strong>On a single core system this would mean:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\" id=\"block-e6c0453b-9f5a-4fbd-8f72-5f0b9ec5386c\"><li>The CPU was fully (100%) utilized on average; 1 processes was running on the CPU (1.00) over the last 1 minute.<\/li><li>The CPU was idle by 60% on average; no processes were waiting for CPU time (0.40) over the last 5 minutes.<\/li><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><\/ul>\n\n\n\n<p id=\"block-53489a82-1e57-408e-a3b6-73774ea9b7bf\"><strong>On a dual-core system this would mean:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\" id=\"block-ecabccc3-31d3-4569-937d-b1e6a1e273bb\"><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><li>The CPUs were idle by 160% on average; no processes were waiting for CPU time. (0.40) over the last 5 minutes.<\/li><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><\/ul>\n\n\n\n<p id=\"block-0f4984c7-78e6-478d-8b60-4e2c4975a125\"><br>We hope you\u2019ve found this useful!&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Description 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&nbsp;\u2013 is a measurement of CPU over or under-utilization in a Linux [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_eb_attr":"","footnotes":""},"categories":[4],"tags":[],"class_list":["post-71","post","type-post","status-publish","format-standard","hentry","category-linux"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/bestdedicatedhosting.in\/blog\/wp-json\/wp\/v2\/posts\/71","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bestdedicatedhosting.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bestdedicatedhosting.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bestdedicatedhosting.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bestdedicatedhosting.in\/blog\/wp-json\/wp\/v2\/comments?post=71"}],"version-history":[{"count":1,"href":"https:\/\/bestdedicatedhosting.in\/blog\/wp-json\/wp\/v2\/posts\/71\/revisions"}],"predecessor-version":[{"id":72,"href":"https:\/\/bestdedicatedhosting.in\/blog\/wp-json\/wp\/v2\/posts\/71\/revisions\/72"}],"wp:attachment":[{"href":"https:\/\/bestdedicatedhosting.in\/blog\/wp-json\/wp\/v2\/media?parent=71"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bestdedicatedhosting.in\/blog\/wp-json\/wp\/v2\/categories?post=71"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bestdedicatedhosting.in\/blog\/wp-json\/wp\/v2\/tags?post=71"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}