Skip to main content

Pod JVM CPU stress

Pod JVM CPU stress injects JVM CPU stress for a Java process executing in a Kubernetes pod by consuming excessive CPU threads of the JVM.

tip

JVM chaos faults use the Byteman utility to inject chaos faults into the JVM.

Pod JVM CPU stress

Use cases

Pod JVM CPU stress:

  • Tests the system's ability to handle high payloads.
  • Evaluates the application's behavior in high-stress cases.
  • Induces CPU consumption and exhaustion on the target Java process JVM executing in a K8s pod.
  • Simulates a lack of CPU threads for processes running on the application, which degrades their performance.
  • Simulates application slowness due to CPU starvation.

Mandatory tunables

Tunable Description Notes
CPU The number of CPU threads that the application should consume. For example, 2.

Optional tunables

Tunable Description Notes
TOTAL_CHAOS_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. For more information, go to duration of the chaos.
POD_AFFECTED_PERC Percentage of total pods to target. Provide numeric values. Default: 0 (corresponds to 1 replica). For more information, go to pods affected percentage
JAVA_HOME Path to the Java installation directory. For example, /tmp/dir/jdk.
BYTEMAN_PORT Port used by the Byteman agent. Default: 9091.
CONTAINER_RUNTIME Container runtime interface for the cluster Default: containerd. Support values: docker, containerd and crio. For more information, go to container runtime.
SOCKET_PATH Path of the containerd or crio or docker socket file. Default: /run/containerd/containerd.sock. For more information, go to socket path.
RAMP_TIME 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. For more information, go to ramp time.
SEQUENCE Sequence of chaos execution for multiple target pods. Default: parallel. Supports serial and parallel. For more information, go to sequence of chaos execution.
TARGET_CONTAINER Name of the container subject to API header modification. None. For more information, go to target specific container
TARGET_PODS Comma-separated list of application pod names subject to pod HTTP modify body. If not provided, the fault selects target pods randomly based on provided appLabels. For more information, go to target specific pods.
NODE_LABEL Node label used to filter the target node if TARGET_NODE environment variable is not set. It is mutually exclusive with the TARGET_NODE environment variable. If both are provided, the fault uses TARGET_NODE. For more information, go to node label.
LIB_IMAGE Image used to inject chaos. Default: harness/chaos-go-runner:main-latest. For more information, go to image used by the helper pod.

Parameters

The following YAML snippet illustrates the use of these tunables.

apiVersion: litmuschaos.io/v1alpha1
kind: KubernetesChaosExperiment
metadata:
name: pod-jvm-cpu-stress
namespace: hce
env:
- name: TOTAL_CHAOS_DURATION
value: "60"
- name: POD_AFFECTED_PERCENTAGE
value: ""
- name: BYTEMAN_PORT
value: "9091"
- name: JAVA_HOME
value: ""
- name: CPU
value: "2"
- name: CONTAINER_RUNTIME
value: containerd
- name: SOCKET_PATH
value: /run/containerd/containerd.sock
- name: LIB_IMAGE
value: docker.io/harness/chaos-ddcr-faults:1.49.2
- name: RAMP_TIME
value: "0"
- name: SEQUENCE
value: parallel
- name: TARGET_CONTAINER
value: ""
- name: TARGET_PODS
value: ""
- name: NODE_LABEL
value: ""