{"id":7839,"date":"2024-10-04T01:13:00","date_gmt":"2024-10-04T05:13:00","guid":{"rendered":"https:\/\/www.both.org\/?p=7839"},"modified":"2024-10-03T21:11:53","modified_gmt":"2024-10-04T01:11:53","slug":"i-found-a-new-way-to-stress-test-my-linux-hosts","status":"publish","type":"post","link":"https:\/\/www.both.org\/?p=7839","title":{"rendered":"I found a new way to stress-test my Linux hosts"},"content":{"rendered":"<div class=\"pld-like-dislike-wrap pld-template-1\">\r\n    <div class=\"pld-like-wrap  pld-common-wrap\">\r\n    <a href=\"javascript:void(0)\" class=\"pld-like-trigger pld-like-dislike-trigger  \" title=\"\" data-post-id=\"7839\" data-trigger-type=\"like\" data-restriction=\"cookie\" data-already-liked=\"0\">\r\n                        <i class=\"fas fa-thumbs-up\"><\/i>\r\n                <\/a>\r\n    <span class=\"pld-like-count-wrap pld-count-wrap\">    <\/span>\r\n<\/div><\/div>\n<p>I just discovered an important little program that allows me to stress-test my Linux hosts. Its name is &#8212; <strong><a href=\"https:\/\/github.com\/resurrecting-open-source-projects\/stress\" data-type=\"link\" data-id=\"https:\/\/github.com\/resurrecting-open-source-projects\/stress\" target=\"_blank\" rel=\"noreferrer noopener\">stress<\/a><\/strong> &#8212; of course. Stress has been around for some time, and this is a resurrection of a previous version, though I can&#8217;t find any information about that earlier one. This incarnation is about three years old and is currently on release 1.0.7. But it&#8217;s new to me as I just discovered it today.<\/p>\n\n\n\n<p>I installed <strong>stress<\/strong> directly from the Fedora repository.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># dnf -y install stress<\/code><\/pre>\n\n\n\n<p>Stress may be available from the repository for your distro, but it&#8217;s also available from GitHub at <a href=\"https:\/\/github.com\/resurrecting-open-source-projects\/stress\">https:\/\/github.com\/resurrecting-open-source-projects\/stress<\/a>.<\/p>\n\n\n\n<p>I read the concise manual page and discovered that <strong>stress<\/strong> can test CPU, memory, raw I\/O, and disk I\/O. Stress has a lot of flexibility; SysAdmins can specify any one or multiple resources to test, and how many worker threads to use. It can run forever or we can specify a timeout.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Check the base state<\/h2>\n\n\n\n<p>Let&#8217;s start with a look at my primary workstation&#8217;s base state in Figure 1 before running any stressors. I do run <a href=\"https:\/\/boinc.berkeley.edu\/\" data-type=\"link\" data-id=\"https:\/\/boinc.berkeley.edu\/\" target=\"_blank\" rel=\"noreferrer noopener\">BOINC<\/a> most of the time to perform calculations for <a href=\"https:\/\/www.worldcommunitygrid.org\/\" data-type=\"link\" data-id=\"https:\/\/www.worldcommunitygrid.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">World Community Grid<\/a>. That takes a lot of CPU, some memory, and some disk I\/O. So we&#8217;ll be looking at the effects that stress has on my system even while running a non-related, significant load. <\/p>\n\n\n\n<p>I&#8217;ve split my <a href=\"https:\/\/www.both.org\/?p=6672\" data-type=\"link\" data-id=\"https:\/\/www.both.org\/?p=6672\" target=\"_blank\" rel=\"noreferrer noopener\">Konsole<\/a> session into two side-by-side terminals and moved the divider to maximize the left side terminal that&#8217;s running <a href=\"https:\/\/glances.readthedocs.io\/en\/develop\/\" data-type=\"link\" data-id=\"https:\/\/glances.readthedocs.io\/en\/develop\/\" target=\"_blank\" rel=\"noreferrer noopener\">glances<\/a>, a powerful and flexible system monitoring tool. The terminal session on the right side is where I enter the commands and it doesn&#8217;t need to be very wide.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><a href=\"http:\/\/www.both.org\/wp-content\/uploads\/2024\/10\/Stress-01.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"2271\" height=\"1222\" src=\"http:\/\/www.both.org\/wp-content\/uploads\/2024\/10\/Stress-01.png\" alt=\"\" class=\"wp-image-7897\" style=\"width:1098px;height:auto\"\/><\/a><figcaption class=\"wp-element-caption\">Figure 1: I use the glances tool to view the state of my system before starting the stress test. Click the image to enlarge.<\/figcaption><\/figure>\n\n\n\n<p>Be sure to click on the images in this article to enlarge them for additional detail.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">CPU<\/h2>\n\n\n\n<p>I used a simple command to begin checking CPU stress. In this case I configured only five worker threads ( -c 5 ), since I had no idea what this would look like or how it would affect my system overall. I also set the verbose flag ( -v ) so I could see some details about what <strong>stress<\/strong> was doing.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>root@david:~# <strong>stress -c 5 -v<\/strong>\nstress: info: &#91;382459] dispatching hogs: 5 cpu, 0 io, 0 vm, 0 hdd\nstress: dbug: &#91;382459] using backoff sleep of 15000us\nstress: dbug: &#91;382459] --&gt; hogcpu worker 5 &#91;382460] forked\nstress: dbug: &#91;382459] using backoff sleep of 12000us\nstress: dbug: &#91;382459] --&gt; hogcpu worker 4 &#91;382461] forked\nstress: dbug: &#91;382459] using backoff sleep of 9000us\nstress: dbug: &#91;382459] --&gt; hogcpu worker 3 &#91;382462] forked\nstress: dbug: &#91;382459] using backoff sleep of 6000us\nstress: dbug: &#91;382459] --&gt; hogcpu worker 2 &#91;382463] forked\nstress: dbug: &#91;382459] using backoff sleep of 3000us\nstress: dbug: &#91;382459] --&gt; hogcpu worker 1 &#91;382464] forked<\/code><\/pre>\n\n\n\n<p>You can see the result in Figure 2. The CPU hogs can be seen near the top of the list of running programs. Of course the total CPU usage hasn&#8217;t changed. <\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><a href=\"https:\/\/www.both.org\/wp-content\/uploads\/2024\/10\/Stress-02.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"2271\" height=\"1222\" src=\"https:\/\/www.both.org\/wp-content\/uploads\/2024\/10\/Stress-02.png\" alt=\"\" class=\"wp-image-7874\" style=\"width:1121px;height:auto\"\/><\/a><figcaption class=\"wp-element-caption\">Figure 2: The CPU worker threads can be seen at the top of the running programs.  Click the image to enlarge.<\/figcaption><\/figure>\n\n\n\n<p>Notice that the World Community Grid (WCG) threads have a nice number of 19, while the CPU worker threads have a nice number of 0, so they take precedence. I spent some time experimenting with larger numbers of workers, 50 was the most, and eventually the WCG threads were getting smaller amounts of CPU time, but still around 50% per thread. I noticed very little effect on my other use such as working with email, writing this article, and using Screenshot to capture these images.<\/p>\n\n\n\n<p>Since I hadn&#8217;t set a time limit, I used <strong>Ctrl+C<\/strong> to terminate <strong>stress<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Memory<\/h2>\n\n\n\n<p>The next thing I tried was stressing RAM. These workers touch otherwise unused RAM to cause it to be allocated in blocks of 268,435,456 bytes, and then they release that memory.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># <strong>stress -m 15<\/strong><\/code><\/pre>\n\n\n\n<p>Figure 3 shows the effects of memory stress. You can see that some additional memory has been allocated over the baseline in Figure 1. More workers would cause more memory to be allocated.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><a href=\"https:\/\/www.both.org\/wp-content\/uploads\/2024\/10\/Stress-03.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"2271\" height=\"1222\" src=\"https:\/\/www.both.org\/wp-content\/uploads\/2024\/10\/Stress-03.png\" alt=\"\" class=\"wp-image-7881\" style=\"width:1115px;height:auto\"\/><\/a><figcaption class=\"wp-element-caption\">Figure 3: Running 15 memory threads. Click the image to enlarge.<\/figcaption><\/figure>\n\n\n\n<p>I tried different numbers of memory worker threads. The most I tried was 75 workers which results in about 65% memory usage. Once again I noticed no significant impact on my normal tasks.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Disk I\/O and raw I\/O<\/h2>\n\n\n\n<p>I did disk I\/O and raw I\/O simultaneously to see how that would work. Like the others, I used only a few worker threads for this test to begin.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># <strong>stress -i 5 -d 5<\/strong><\/code><\/pre>\n\n\n\n<p>Figure 4 shows the effects that this has on I\/O. The disk I\/O section in the left sidebar shows large data writes to multiple devices while the process section shows the I\/O activity for the individual worker processes.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><a href=\"https:\/\/www.both.org\/wp-content\/uploads\/2024\/10\/Stress-04.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"2271\" height=\"1222\" src=\"https:\/\/www.both.org\/wp-content\/uploads\/2024\/10\/Stress-04.png\" alt=\"\" class=\"wp-image-7885\" style=\"width:1081px;height:auto\"\/><\/a><figcaption class=\"wp-element-caption\">Figure 4: Running disk and raw I\/O tests at the same time. Click the image to enlarge.<\/figcaption><\/figure>\n\n\n\n<p>I found that using <strong>htop<\/strong> instead of <strong>glances<\/strong> to monitor I\/O gives a different, and I think more concise picture of I\/O, especially on the I\/O tab and the Disk I\/O line in the summary section, if you&#8217;ve added that to the view. It&#8217;s not different information, it&#8217;s just presented in a different manner. <\/p>\n\n\n\n<p>Using each of these options separately, I was able to see that DIsk I\/O and raw I\/O both use disk I\/O as their stressors. It does seem that they work a bit differently and produce a somewhat different result. Nevertheless it&#8217;s essentially the same test. Not that there&#8217;s any other device commonly used on most computers that could be used to test I\/O.<\/p>\n\n\n\n<p>Once again, I experienced no noticeable impact on the responsiveness of my system when performing normal activities.<\/p>\n\n\n\n<p>However, I also discovered that in around a couple hours &#8212; on a different host &#8212; the disk filled up when testing disk I\/O. This produced errors in the terminal in which I ran the program. In Figure 5 you can see that I was testing all four stressors with 20 worker threads each. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># <strong>stress -d 20 -m 20 -c 20 -i 20 -t 7200<\/strong>\nstress: info: &#91;536717] dispatching hogs: 20 cpu, 20 io, 20 vm, 20 hdd\nstress: FAIL: &#91;536777] (599) stress: FAIL: &#91;536797] (599) write failed: No space left on device\nwrite failed: No space left on device\nstress: FAIL: &#91;536749] (599) write failed: No space left on device\nstress: FAIL: &#91;536781] (599) write failed: No space left on device\nstress: FAIL: &#91;536769] (599) write failed: No space left on device\nstress: FAIL: &#91;536785] (599) write failed: No space left on device\nstress: FAIL: &#91;536721] (599) stress: FAIL: &#91;536753] (599) write failed: No space left on device\nwrite failed: No space left on device\nstress: FAIL: &#91;536745] (599) stress: FAIL: &#91;536729] (599) write failed: No space left on device\nwrite failed: No space left on device\nstress: FAIL: &#91;536737] (599) write failed: No space left on device\nstress: FAIL: &#91;536765] (599) write failed: No space left on device\nstress: FAIL: &#91;536725] (599) write failed: No space left on device\n&lt;SNIP><\/code><\/pre>\n\n\n\n<p class=\"has-text-align-center has-small-font-size\">Figure 5: Stress did fill up the filesystem on another host when testing disk and raw I\/O. <\/p>\n\n\n\n<p>The space on the filesystem was de-allocated when stress completed the full two hours. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<p>Stress is a cool but basic tool that allows stress-testing of memory, CPU, disk, and raw I\/O. It doesn&#8217;t currently provide tests for GPU, display, or network. While that can be limiting in some environments, it provides solid stressors for the big four that affect everyone.<\/p>\n\n\n\n<p>There&#8217;s a lot of interesting information to be had from the <strong>stress<\/strong> tool. I find it interesting to watch as the hogs ramp up very quickly and then as the effects drop down when the program is terminated. CPU and I\/O drops off as soon as the hogs terminate. Memory is de-allocated and returned to the memory pool much more slowly. This provides some insight into how the kernel manages memory, while suggesting some lines for additional testing. For example, does de-allocation occur faster in low memory environments? <\/p>\n\n\n\n<p>Activity for other tests drops off directly as the workers are terminated. This can take a few seconds &#8212; more if you&#8217;ve started a large number of worker threads.<\/p>\n\n\n\n<p>I&#8217;ve added <strong>stress<\/strong> to my toolkit for testing newly built or rebuilt systems. <\/p>\n\n\n\n<p>The stress project is looking for programmers to help with development. Apply at <a href=\"https:\/\/github.com\/resurrecting-open-source-projects\/stress\">https:\/\/github.com\/resurrecting-open-source-projects\/stress<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I just discovered an important little program that allows me to stress-test my Linux hosts. Its name is<\/p>\n","protected":false},"author":2,"featured_media":4837,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[5],"tags":[],"class_list":["post-7839","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux"],"modified_by":"David Both","_links":{"self":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/7839","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7839"}],"version-history":[{"count":27,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/7839\/revisions"}],"predecessor-version":[{"id":7907,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/7839\/revisions\/7907"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/media\/4837"}],"wp:attachment":[{"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7839"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7839"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7839"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}