Skip to main content

VMware memory hog

VMware memory hog fault consumes excessive memory resources on Linux OS based VMware VMs. It determines the performance of the application running on the VMware VMs. 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.

VMware Memory Hog

Use cases

  • VMware memory hog determines the resilience of an application to unexpected consumption of excessive memory by application resources.
  • It simulates the situation of memory leaks in the deployment of microservices.
  • It simulates application slowness due to memory starvation.
  • It also simulates noisy neighbour problems due to hogging.
  • It verifies pod priority and QoS setting for eviction purposes.
  • It also verifies application restarts on OOM (out of memory) kills.
tip

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.

Prerequisites

  • Kubernetes > 1.16 is required to execute this fault.
  • Execution plane should be connected to vCenter and host vCenter on port 443.
  • The VM should be in a healthy state before and after injecting chaos.
  • VMware tool should be installed on the target VM with remote execution enabled.
  • Appropriate vCenter permissions should be provided to access the hosts and the VMs.
  • Kubernetes secret has to be created that has the Vcenter credentials in the CHAOS_NAMESPACE. VM credentials can be passed as secrets or as a ChaosEngine environment variable. Below is a sample secret file:
apiVersion: v1
kind: Secret
metadata:
name: vcenter-secret
namespace: litmus
type: Opaque
stringData:
VCENTERSERVER: XXXXXXXXXXX
VCENTERUSER: XXXXXXXXXXXXX
VCENTERPASS: XXXXXXXXXXXXX

Mandatory tunables

Tunable Description Notes
VM_NAME Name of the target VM. For example, ubuntu-vm-1.
VM_USER_NAME Username of the target VM. For example, vm-user.
VM_PASSWORD User password for the target VM. For example, 1234. Note: You can take the password from secret as well.

Optional tunables

Tunable Description Notes
MEMORY_CONSUMPTION_MEBIBYTES Amount of memory consumed by VMware VMs (in MiB). For example, 4024. For more information, go to memory consumption in mebibytes.
MEMORY_CONSUMPTION_PERCENTAGE Amount of total memory to be consumed (in percentage). Default to 100. For more information, go to memory consumption in percentage.
NUMBER_OF_WORKERS Number of workers used to run the stress process. Defaults to 4. For more information, go to workers for stress.
TOTAL_CHAOS_DURATION Duration that you specify, through which chaos is injected into the target resource (in seconds). Defaults to 30s. For more information, go to duration of the chaos.
CHAOS_INTERVAL Time interval between two successive instance terminations (in seconds). Defaults to 30s. For more information, go to chaos interval.
SEQUENCE Sequence of chaos execution for multiple instances. Defaults to parallel. Supports serial sequence as well. For more information, go to sequence of chaos execution.
RAMP_TIME Period to wait before and after injecting chaos (in seconds). For example, 30s. For more information, go to ramp time.
DEFAULT_HEALTH_CHECKDetermines if you wish to run the default health check which is present inside the fault. Default: 'true'. For more information, go to default health check.

Memory consumption in percentage

It specifies the memory consumed by the target VM (in percentage). Tune it by using the MEMORY_CONSUMPTION_PERCENTAGE environment variable.

Use the following example to tune it:

# Memory hog in the VMware VM
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: engine-nginx
spec:
engineState: "active"
chaosServiceAccount: litmus-admin
experiments:
- name: VMware-memory-hog
spec:
components:
env:
# Name of the VM
- name: VM_NAME
value: 'test-vm-01'
# memory consumption value
- name: MEMORY_CONSUMPTION_PERCENTAGE
value: '50'

Memory consumption in mebibytes

It specifies the memory consumed by the target VM in mebibytes (MiB). Tune it by using the MEMORY_CONSUMPTION_MEBIBYTES environment variable.

Use the following example to tune it:

# Memory hog in the VMware VM
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: engine-nginx
spec:
engineState: "active"
chaosServiceAccount: litmus-admin
experiments:
- name: VMware-memory-hog
spec:
components:
env:
# Name of the VM
- name: VM_NAME
value: 'test-vm-01'
# memory consumption value
- name: MEMORY_CONSUMPTION_MEBIBYTES
value: '500'

Workers for stress

It specifies the worker's count for stress. Tune it by using the NUMBER_OF_WORKERS environment variable.

Use the following example to tune it:

# Memory hog in the VMware VM
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: engine-nginx
spec:
engineState: "active"
chaosServiceAccount: litmus-admin
experiments:
- name: VMware-memory-hog
spec:
components:
env:
# Name of the VM
- name: VM_NAME
value: 'test-vm-01'
# Number of workers for stress
- name: NUMBER_OF_WORKERS
value: '4'