Pages

Thursday, June 29, 2017

How to Impose High CPU Load and Stress Test on Linux Using ‘Stress-ng’ Tool

As a System Administrator, you may want to examine and monitor the status of your Linux systems when they are under stress of high load. This can be a good way for System Administrators and Programmers to:
  1. fine tune activities on a system.
  2. monitor operating system kernel interfaces.
  3. test your Linux hardware components such as CPU, memory, disk devices and many others to observe their performance under stress.
  4. measure different power consuming loads on a system.
Linux CPU Load Stress Test Tool
Linux CPU Load Stress Test with Stress-ng Tool
In this guide, we shall look at two important tools, stress and stress-ng for stress testing under your Linux systems.
1. stress – is a workload generator tool designed to subject your system to a configurable measure of CPU, memory, I/O and disk stress.
2. stress-ng – is an updated version of the stress workload generator tool which tests your system for following features:
  1. CPU compute
  2. drive stress
  3. I/O syncs
  4. Pipe I/O
  5. cache thrashing
  6. VM stress
  7. socket stressing
  8. process creation and termination
  9. context switching properties
Though these tools are good for examining your system, they should not just be used by any system user.
Important: It is highly recommended that you use these tools with root user privileges, because they can stress your Linux machine so fast and to avoid certain system errors on poorly designed hardware.

How to Install ‘stress’ Tool in Linux

To install stress tool on Debian and its derivatives such Ubuntu and Mint, run the following command.
$ sudo apt-get install stress
Install stress in Debian and Ubuntu
To install stress on a RHEL/CentOS and Fedora Linux, you need to turn on EPEL repository and then type the following yum command to install the same:
# yum install stress
The general syntax for using stress is:
$ sudo stress option argument
Some options that you can use with stress.
  1. To spawn N workers spinning on sqrt() function, use the –cpu N option as follows.
  2. To spawn N workers spinning on sync() function, use the –io N option as follows.
  3. To spawn N workers spinning on malloc()/free() functions, use the –vm N option.
  4. To allocate memory per vm worker, use the –vm-bytes N option.
  5. Instead of freeing and reallocating memory resources, you can redirty memory by using the –vm-keepoption.
  6. Set sleep to N seconds before freeing memory by using the –vm-hang N option.
  7. To spawn N workers spinning on write()/unlink() functions, use the –hdd N option.
  8. You can set a timeout after N seconds by using the –timeout N option.
  9. Set a wait factor of N microseconds before any work starts by using the –backoff N option as follows.
  10. To show more detailed information when running stress, use the -v option.
  11. Use –help to view help for using stress or view the manpage.

How Do I use stress on Linux systems?

1. To examine effect of the command every time you run it, first run the uptime command and note down the load average.
Next, run the stress command to spawn 8 workers spinning on sqrt() with a timeout of 20 seconds. After running stress, again run the uptime command and compare the load average.
      ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
                                                    ► Read more: http://adf.ly/1nBgQe
      ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

No comments:

Post a Comment