Member-only story
Attack CPU, Memory of a Linux machine using Stress and Stress-ng commands
It's critical to measure and monitor, of course then take mitigating actions on how our applications behave in case of CPU and memory spike. So as part of application chaos/reliability testing, We need to generate CPU, memory spikes on our systems.
There are so many tools out there in the market which can do these types of attacks. But we can use available simple Linux utilities like Stress and Stress-ng for this purpose.
stress — is a workload generator tool designed for POSIX systems. It can generate a configurable amount of CPU, memory, I/O, and disk stress on your machine.
stress-ng — is an updated version of the stress workload generator tool which tests your system for the following features:
- CPU compute
- drive stress
- I/O syncs
- Pipe I/O
- cache thrashing
- VM stress
- socket stressing
- process creation and termination
- context switching properties
First, we need to install these tools on the machines which need to be attacked.
The following steps can be used based on your system
For Debian, Ubuntu, and Mint
sudo apt-get install stresssudo apt-get install stress-ng