You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -54,8 +55,42 @@ Notice that even though the total test duration is 10s, the actual execution tim
54
55
because of `gracefulStop`, giving the VUs a 3s additional time to complete iterations in progress. 23
55
56
of the iterations currently in progress did not complete within this window and was therefore interrupted.
56
57
57
-
## Additional Information
58
+
## The `gracefulRampDown`
59
+
60
+
In addition to `gracefulStop`, the [ramping-vus](/using-k6/scenarios/executors/ramping-vus) executor also has a `gracefulRampDown`.
61
+
62
+
When the target value for a stage is lower than the target for the previous stage, k6 might need to stop some VUs that were started during the previous stages.
63
+
The `gracefulRampDown` option controls how long these VUs have to finish currently before k6 interrupts them.
64
+
65
+
To get an idea of how `gracefulRampDown` works, you can run the following script with
66
+
`k6 run --verbose`.
67
+
In this script, the iteration `sleep` time exceeds the `gracefulRampdown` time.
68
+
So, as k6 ramps down to reach the target of the second stage, it must forcibly interrupt VUs.
69
+
The `--verbose` flag will log to your console when VUs start, enter the grace period, and are forcibly interrupted.
70
+
71
+
```javascript
72
+
importhttpfrom"k6/http";
73
+
import { sleep } from"k6";
74
+
75
+
exportconstoptions= {
76
+
discardresponsebodies:true,
77
+
scenarios: {
78
+
contacts: {
79
+
executor:"ramping-vus",
80
+
startvus:0,
81
+
stages: [
82
+
{ duration:"10s", target:10 },
83
+
{ duration:"10s", target:0 },
84
+
],
85
+
gracefulRampDown:"1s",
86
+
},
87
+
},
88
+
};
89
+
90
+
exportdefaultfunction () {
91
+
http.get("https://test.k6.io/contacts.php");
92
+
// adding sleep beyond so that iterations are longer than rampdown
93
+
sleep(5);
94
+
}
95
+
```
58
96
59
-
A similar option exists for the [ramping-vus](/using-k6/scenarios/executors/ramping-vus) executor: `gracefulRampDown`. This
60
-
specifies the time k6 should wait for any iterations in progress to finish before
61
-
VUs are returned to the global pool during a ramp down period defined in `stages`.
0 commit comments