Skip to main content

Linux CPU stress

Linux CPU stress fault applies stress on the CPU of the target Linux machines for a specific duration.

Linux CPU stress

Use cases

  • Induces CPU stress on the target Linux machines.
  • Simulates a lack of CPU for processes running on the application, which degrades their performance.
  • Simulates slow application traffic or exhaustion of the resources, leading to degradation in the performance of processes on the machine.
note
  • This fault can be executed on Ubuntu 16 or higher, Debian 10 or higher, CentOS 7 or higher, RHEL 7 or higher, Fedora 30 or higher, and openSUSE LEAP 15.4 or higher.
  • The linux-chaos-infrastructure systemd service should be in an active state, and the infrastructure should be in CONNECTED state.

Fault permissions

The fault uses the root Linux user and root user group.

External packages

This fault uses stress-ng, which is installed as part of the infrastructure installation.

Optional tunables

Tunable Description Notes
load Percentage load to be exerted on a single CPU core. Default: 100 %.
workers Number of worker processes to start. Corresponds to the number of CPU cores to consume. Default: 1.
duration Duration through which chaos is injected into the target resource. Should be provided in [numeric-hours]h[numeric-minutes]m[numeric-seconds]s format. Default: 30s. Examples: 1m25s, 1h3m2s, 1h3s
rampTime Period to wait before and after injecting chaos. Should be provided in [numeric-hours]h[numeric-minutes]m[numeric-seconds]s format. Default: 0s. Examples: 1m25s, 1h3m2s, 1h3s

Workers

The workers input variable utilizes a specific number of workers for the CPU stress fault.

The following YAML snippet illustrates the use of this environment variable:

# workers to utilize
apiVersion: litmuchaos.io/v1alpha1
kind: LinuxFault
metadata:
name: linux-cpu-stress
labels:
name: cpu-stress
spec:
stressChaos/inputs:
workers: 1
load: 100

Load percentage

The load input variable exerts the CPU load (in percentage) per core.

The following YAML snippet illustrates the use of this environment variable:

# percentage load to exert per core
apiVersion: litmuchaos.io/v1alpha1
kind: LinuxFault
metadata:
name: linux-cpu-stress
labels:
name: cpu-stress
spec:
stressChaos/inputs:
workers: 3
load: 70