Load Profiles and Ramping
- Overview
- Quick Start
- Predefined Load Patterns
- Explicit Executor Selection
- Fully Custom Scenarios
- Maven Configuration
- Parameter Reference
- Combined Scenarios
- Duration Format
- Choosing a Configuration
Overview
By default, the loadtest:run goal uses a ramp load pattern that gradually increases virtual users to the target count, sustains the load, then ramps back down.
This produces more realistic traffic than an instant spike and avoids overwhelming the application at startup.
Load profiles control the shape of the traffic curve — how many virtual users (VUs) are active at each point during the test. Three levels of configuration are available:
-
Predefined patterns — convenient presets (
ramp,constant,stress,soak,customstages) that map to k6’sconstant-vusandramping-vusexecutors. -
Explicit executor selection — direct use of any k6 executor (
constant-arrival-rate,shared-iterations, etc.) with full parameter control. -
Fully custom scenarios — raw k6 scenario JavaScript for maximum flexibility.
Configuration priority (highest to lowest): k6.customScenario > k6.executor > k6.stages > k6.loadPattern.
Quick Start
Source code
Default behavior (ramp up 10 s, sustain, ramp down 10 s)
mvn loadtest:run -Dk6.vus=50 -Dk6.duration=2mSource code
Constant load (no ramping, previous default behavior)
mvn loadtest:run -Dk6.vus=50 -Dk6.duration=2m -Dk6.loadPattern=constantSource code
Custom ramp durations
mvn loadtest:run -Dk6.vus=50 -Dk6.duration=5m -Dk6.rampUp=30s -Dk6.rampDown=15sSource code
Fully custom stages
mvn loadtest:run -Dk6.stages="30s:20,1m:50,30s:50,15s:80,1m:80,30s:0"Source code
Constant arrival rate (explicit executor)
mvn loadtest:run -Dk6.executor=constant-arrival-rate -Dk6.rate=100 \
-Dk6.duration=2m -Dk6.preAllocatedVUs=50 -Dk6.maxVUs=200Source code
Shared iterations (explicit executor)
mvn loadtest:run -Dk6.executor=shared-iterations -Dk6.vus=50 \
-Dk6.iterations=1000 -Dk6.duration=5mPredefined Load Patterns
| Pattern | Description |
|---|---|
| Ramp up to target VUs, sustain at full load, then ramp down to 0.
Ramp-up and ramp-down durations are configurable via |
| All VUs start immediately and run for the full duration.
No ramp-up or ramp-down phase.
Uses k6’s |
| Gradually increases load beyond normal capacity with a spike phase. Stages: 50% VUs → 100% VUs → sustain → 150% spike → ramp down. Useful for finding the breaking point of the application. |
| Quick ramp-up (5% of duration), extended sustain at target load (90%), quick ramp-down (5%). Designed for long-duration tests to detect memory leaks and gradual degradation. |
| User-defined stages via the |
Ramp Pattern (Default)
The ramp pattern divides the total duration into three phases:
-
Ramp-up — linearly increases VUs from 0 to the target over
k6.rampUpduration (default10s). -
Sustain — holds at target VUs for the remaining time.
-
Ramp-down — linearly decreases VUs from target to 0 over
k6.rampDownduration (default10s).
The sustain duration is automatically calculated: duration - rampUp - rampDown.
If rampUp + rampDown exceeds the total duration, both are scaled down proportionally.
Stress Pattern
The stress pattern is designed to push the application beyond its normal operating limits:
Five stages, each a percentage of total duration:
-
10% — ramp to 50% of target VUs
-
10% — ramp to 100% of target VUs
-
40% — sustain at 100%
-
20% — spike to 150% of target VUs
-
20% — ramp down to 0
Soak Pattern
The soak pattern maximizes time at target load for long-running stability tests:
Three stages:
-
5% of duration — ramp to target VUs
-
90% of duration — sustain at target
-
5% of duration — ramp down to 0
Custom Stages
For full control, define explicit stages as duration:target pairs.
When k6.stages is set, the load pattern is automatically set to custom and the k6.vus / k6.duration parameters are ignored.
Source code
Stage format
duration:target,duration:target,...-
duration — a k6 time string (
10s,1m,2m30s,1h) -
target — the VU count to ramp to by the end of this stage
Each stage linearly transitions from the previous stage’s ending VU count (or 0 for the first stage) to its own target over the given duration.
To hold load steady, repeat the same target in consecutive stages (e.g. 1m:50,30s:50 ramps to 50 then holds at 50 for 30 s).
Source code
Example: gradual ramp with plateau and spike
mvn loadtest:run -Dk6.stages="30s:20,1m:50,30s:50,15s:80,1m:80,30s:0"This produces:
Reading the stages left to right:
-
30s:20— ramp from 0 to 20 VUs over 30 seconds -
1m:50— ramp from 20 to 50 VUs over 1 minute -
30s:50— hold at 50 VUs for 30 seconds (same target = plateau) -
15s:80— ramp from 50 to 80 VUs over 15 seconds -
1m:80— hold at 80 VUs for 1 minute -
30s:0