TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/grafana/k6/llms.txt
Use this file to discover all available pages before exploring further.
per-vu-iterations executor ensures that each VU runs an exact number of iterations. Unlike shared iterations where VUs compete for iterations, here every VU completes its own fixed quota of iterations.
How It Works
With per-VU iterations:- Each VU is assigned a fixed number of iterations
- VUs run independently without competing
- Total iterations =
vus × iterations - Each VU completes all its iterations or runs until
maxDuration - All VUs complete the same number of iterations (if within maxDuration)
Configuration
Must be
per-vu-iterationsNumber of VUs to run concurrently. Must be greater than 0.
Number of iterations each VU executes. Must be greater than 0.
Maximum duration for the executor. If a VU’s iterations don’t complete within this time, remaining iterations are dropped.
Example
Basic Configuration
Per-User Session Simulation
When to Use
Use the per-VU iterations executor when:- You want consistent work per VU (e.g., each user completes 10 sessions)
- You need predictable per-VU behavior for testing
- You’re simulating realistic user behavior where each user does a set amount of work
- You want the total iterations to scale linearly with VUs
- You need to test with isolated per-VU data or state
Behavior Details
Total Iterations
The total number of iterations is the product of VUs and iterations per VU:VU Isolation
Each VU maintains its own iteration counter and executes independently:Maximum Duration
If a VU cannot complete all iterations withinmaxDuration, remaining iterations are dropped:
dropped_iterations metric.
Scaling Behavior
Example with 50% execution segment:Metrics
The executor emits these metrics:iterations- Total completed iterations across all VUsiteration_duration- Time to complete each iterationdropped_iterations- Iterations that didn’t complete withinmaxDuration(tracked per VU)vus- Number of active VUsvus_max- Maximum number of VUs
Common Patterns
User Journey Testing
Per-VU Data Processing
Ramping Users with Fixed Work
Combine with other executors for complex scenarios:Comparison with Shared Iterations
| Feature | Per VU Iterations | Shared Iterations |
|---|---|---|
| Total iterations | vus × iterations | Fixed total |
| Distribution | Even (each VU does same) | Dynamic (faster VUs do more) |
| VU workload | Equal | Unequal |
| Predictability | High per-VU | High total |
| Scaling | Linear with VUs | Independent of VUs |
| Use case | Consistent per-user load | Fixed total work |
Best Practices
- Set realistic maxDuration: Ensure each VU has enough time to complete all iterations
- Use for user simulation: Great for simulating N users each doing M actions
- Monitor per-VU metrics: Use
__VUand__ITERto track per-VU behavior - Consider VU reuse: VUs are reused across iterations, so handle state appropriately
- Plan for scaling: Remember only VUs scale in distributed testing, not iterations
See Also
- Shared Iterations - Fixed total iterations shared among VUs
- Constant VUs - Time-based execution with fixed VUs