Skip to main content

Linux memory stress

Linux memory stress causes memory consumption on the target Linux machines for a specific duration. This fault allocates and maps a specific amount of virtual address space and keeps rewriting to that same memory space for the chaos duration before unmapping it.

Linux memory stress

Use cases

  • Induces memory consumption and exhaustion on the target Linux machines.
  • Simulates a lack of memory for processes running on the application, which degrades their performance.
  • Simulates application slowness due to memory starvation, and noisy neighbour problems due to excessive consumption of memory.
note

The mapped memory space is unmapped only after the chaos duration; the same memory space is used to write data into memory in an iterative manner. This way, constant memory is consumed throughout the fault duration.

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.

Fault tunables

Optional tunables

Tunable Description Notes
memory Amount of memory to be consumed. Can be specified in bytes (b/B), kilobytes (k/K), megabytes (m/M), gigabytes (g/G), or percentage (%) of available storage. If no unit is provided, the value is assumed to be in bytes. Example values: 30m, 1G, 35%, etc. Default: 256m
workers Number of worker processes to start. 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 memory stress fault.

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

# workers to utilize
apiVersion: litmuchaos.io/v1alpha1
kind: LinuxFault
metadata:
name: linux-memory-stress
labels:
name: memory-stress
spec:
stressChaos/inputs:
workers: 1
memory: 5g

Memory consumption

The memory input variable specifies the amount of memory to be filled.

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

# memory to consume
apiVersion: litmuchaos.io/v1alpha1
kind: LinuxFault
metadata:
name: linux-memory-stress
labels:
name: memory-stress
spec:
stressChaos/inputs:
workers: 1
memory: 50%