![Lead Image © Lucy Baldwin, 123RF.com Lead Image © Lucy Baldwin, 123RF.com](/var/ezflow_site/storage/images/archive/2019/53/logical-bombs-for-fun-and-benchmarking/123rf_9719495_martialarts_lucybaldwin_resized.png/167333-1-eng-US/123RF_9719495_MartialArts_LucyBaldwin_resized.png_medium.png)
Lead Image © Lucy Baldwin, 123RF.com
Logical Bombs for Fun and Benchmarking
Explosive Code
In this column, I often make use of the stress
[1] utility as a convenient way to generate load on a system's memory, CPU, or storage subsystem. Although not the most sophisticated of tools, load generators like stress
are simple to use and effective, because they provide a convenient way to load a certain number of CPU cores or to fill a predefined amount of RAM and do so in a manner that can be reproduced with consistency. However, you can find other minimalist ways to generate load easily with shell commands. For example, with
$ yes > /dev/null &
the yes
[2] command repeatedly outputs a string until killed and would normally be bound by the I/O speed of the terminal. Because the output is redirected into the oblivion that is /dev/null
before it ever reaches the screen buffers, each such invocation is essentially a pure processor workload that will maximally use up to one CPU core while taking up close to zero I/O or memory resources.
The top
[3] command displays a perfect 1.00 load average after one minute (Figure 1). Amazon CloudWatch [4] data for this test instance more slowly converges on 100% CPU, consistent with the single vCPU configuration of a t2.micro
instance (Figure 2).
Buy this article as PDF
(incl. VAT)