k6 pause/resume/scale
Control a running k6 test through REST API commands.Description
While a k6 test is running with thek6 run command, it exposes a REST API that allows you to:
- Pause - Temporarily stop test execution
- Resume - Continue a paused test
- Scale - Dynamically adjust the number of VUs
localhost:6565).
k6 pause
Synopsis
Description
Pause a currently running test. When paused:- VUs stop executing new iterations
- Current iterations complete
- The test timer continues
- Metrics collection continues
Examples
Use Cases
- Debug issues during test execution
- Wait for external system stabilization
- Manually control test phases
k6 resume
Synopsis
Description
Resume a paused test. VUs will continue executing iterations from where they left off.Examples
k6 scale
Synopsis
Description
Dynamically scale the number of VUs in a running test. You can adjust:- Active VUs (
--vus) - Currently executing VUs - Max VUs (
--max) - VU capacity/pool size
--vus or --max must be specified.
Examples
Flags
Number of virtual users to scale to. Must be less than or equal to max VUs.
Maximum available virtual users. This sets the VU pool capacity.
Constraints
- Active VUs cannot exceed max VUs
- Cannot scale beyond resource limits
- Some executors don’t support dynamic scaling
Global Flags
All control commands support:Address of the k6 REST API server
REST API Endpoints
These commands are wrappers around REST API calls:PATCH /v1/status
The underlying API endpoint for all control operations:Output
All commands return the current test status in YAML format:status- Current test state (init,running,paused,finished)paused- Whether the test is pausedvus- Current active VUsvus-max- Maximum VU capacitytainted- Whether the test has been modified during execution
Enabling the API Server
By default, the REST API is available onlocalhost:6565. To customize:
Use Cases
Manual Load Testing
Manually control load during exploratory testing:Reactive Scaling
Adjust load based on external metrics:Debugging
Pause execution to investigate:Coordinated Testing
Synchronize multiple test instances:Limitations
Executor Compatibility
Not all executors support dynamic control:| Executor | Pause/Resume | Scale |
|---|---|---|
| shared-iterations | ✅ | ❌ |
| per-vu-iterations | ✅ | ❌ |
| constant-vus | ✅ | ✅ |
| ramping-vus | ✅ | ⚠️ |
| constant-arrival-rate | ✅ | ✅ |
| ramping-arrival-rate | ✅ | ⚠️ |
| externally-controlled | ✅ | ✅ |
State Consistency
When pausing/resuming:- Test duration continues
- Iterations in progress complete
- Some timing may be affected
- Metrics reflect actual execution time
Resource Limits
Scaling is constrained by:- System memory
- CPU cores
- Network connections
- File descriptors
See Also
- k6 run - Start a test with the REST API
- REST API documentation
- externally-controlled executor