Stress Test CPU and Memory (VM) On a Linux / Unix With Stress-ng

You can perform a stress test on your CPU and memory (in a virtual machine) on a Linux/Unix system using the stress-ng tool. stress-ng is a stress testing tool that can be used to test various aspects of a Linux/Unix system, including the CPU and memory.

To stress test the CPU, you can use the following command:

stress-ng --cpu N

Where N is the number of CPU cores to stress. For example, to stress all 4 cores, you would use the command:

stress-ng --cpu 4

To stress test memory, you can use the following command:

stress-ng --vm N --vm-bytes MB

Where N is the number of virtual memory stress worker threads and MB is the amount of memory to allocate per thread in MB. For example, to stress 4 GB of memory with 4 threads, you would use the command:

stress-ng --vm 4 --vm-bytes 1024

Note that stress testing the system can be resource-intensive and may result in high CPU and memory usage. It is recommended to only perform stress tests on a system that you have permission to use for this purpose and to monitor the system’s resource usage during the test to ensure it does not become unstable.

Leave a Comment