StressChaos allows you to simulate resource pressure by generating CPU and memory stress on target pods to test application behavior under resource constraints.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/chaos-mesh/chaos-mesh/llms.txt
Use this file to discover all available pages before exploring further.
Supported Stressors
StressChaos supports two primary types of resource stress:- CPU Stress: Generate CPU load to simulate high CPU usage
- Memory Stress: Consume memory to simulate memory pressure
Configuration
Basic Example
Spec Fields
Specifies the target pods for the chaos experiment. See PodChaos documentation for selector details.
Selection mode:
one, all, fixed, fixed-percent, or random-max-percentDuration of the chaos action. Format: “300ms”, “1.5h”, “2h45m”
List of container names to inject stress into. If not set, the first container will be injected.
Stressor configuration. At least one stressor (CPU or memory) must be specified.
Experimental feature: Advanced stress-ng stressors in stress-ng dialect. When both
stressngStressors and stressors are defined, stressngStressors takes precedence. See man stress-ng for available options.Remote cluster where chaos will be deployed
Examples
CPU Stress
Generate 100% CPU load on one worker:Memory Stress
Consume 10GB of memory:Combined CPU and Memory Stress
Stress both CPU and memory simultaneously:Memory Pressure with Percentage
Consume 50% of available memory:Use Cases
Testing Resource Limits
Use StressChaos to verify that Kubernetes resource limits (CPU and memory) are correctly configured and enforced.OOM Testing
Generate memory pressure to test how your application handles out-of-memory conditions and verify OOM killer behavior.Performance Under Load
Simulate high CPU usage to test application performance degradation and ensure critical paths remain responsive.Auto-scaling Validation
Trigger resource stress to verify that horizontal and vertical pod autoscaling mechanisms work as expected.Resource Contention
Test how your application behaves when competing for resources with other workloads.Best Practices
- Worker Count: Start with 1-2 workers and increase gradually to understand impact
- CPU Load: Use
loadparameter to create partial CPU stress (e.g., 50% instead of 100%) for more realistic scenarios - Memory Size: Be careful with memory stress - set appropriate values to avoid node-level issues
- OOM Score: Use
oomScoreAdj: -1000to prevent stress processes from being killed first - Resource Limits: Ensure target pods have resource limits defined to contain the stress impact
- Duration: Use shorter durations initially (30s-60s) to understand system behavior
- Monitor Impact: Watch for:
- Pod evictions
- Node memory/CPU pressure
- Application performance metrics
- Kubernetes events
- Container Selection: When using multi-container pods, specify
containerNamesto target the right container - Mode Selection: Start with
mode: onebefore affecting multiple pods
Advanced Usage
Using stress-ng Options
You can pass additional stress-ng options for fine-grained control:Experimental stressngStressors
For advanced use cases, use raw stress-ng dialect:Notes
- StressChaos uses stress-ng under the hood to generate resource stress
- CPU stress uses the sqrt method by default with CPU load slicing for better accuracy
- Memory stress allocates virtual memory and actively uses it to create pressure
- The chaos daemon runs stress processes inside target containers
- Maximum of 8192 workers can be specified per stressor
- When
stressngStressorsis specified, it overrides thestressorsfield - Resource stress can impact the entire node if not properly contained with resource limits
- Always test in non-production environments first to understand the impact