Execution Control: Termination, Failure, and Retry Rules
This guide demonstrates execution-control features: optional termination grace periods, expression conditions, skipped-count checks in the metric field, and retry delay strategies.
Duration expression path note:
- Runtime Duration metrics are nested objects under
Duration. - Use paths like
Duration.TotalTime.P90(notDuration.P90ResponseTime).
Throughput expression path note:
- RPS means requests per second. LPS currently calculates it using successful requests divided by elapsed seconds, excluding failed requests.
Throughput.RPSandThroughput.RequestsRate.Valueexpose the same rate.- The termination and failure plans below request HTTP 500 responses. With only those responses, the rate remains zero: the low-throughput condition can match, but the
> 100throughput conditions cannot. Other OR conditions can still trigger.
Termination Rules
Termination rules stop a running iteration. Within a rule, metric and expression are independent OR triggers; any rule can terminate the iteration.
An omitted gracePeriod defaults to zero: a matching trigger can terminate at the next termination evaluation, not synchronously with each response. With a nonzero grace period, each trigger is tracked independently and must remain true at successive evaluations for that period. A false evaluation resets that trigger's timer; expression does not bypass the grace period.
name: TerminationFeaturesPlan
rounds:
- name: TerminationRound
numberOfClients: 10
iterations:
- name: SearchIteration
mode: R
requestCount: 5
httpRequest:
url: https://httpbin.org/status/500
method: GET
terminationRules:
- metric: "ErrorRate > 0.10"
expression: "${Metrics.TerminationRound.SearchIteration.Throughput.RequestsRate.Value} <50"
gracePeriod: "00:00:05"
- metric: "SkippedRequestsCount > 25"
expression: "${Metrics.TerminationRound.SearchIteration.Throughput.RequestsRate.Value} > 100"
Expected behavior:
- Rule 1: the iteration can terminate when either
ErrorRate > 0.10or the low-throughput expression remains true for five seconds. The two conditions do not need to be true together. - Rule 2: with no grace period, the iteration can terminate at the next evaluation when either
SkippedRequestsCount > 25or the high-throughput expression is true. - These are alternative triggers, not a sequence of expected events. Low throughput can occur during startup, and a short iteration may finish before a five-second grace period elapses.
- This plan does not configure request skipping, so its skipped-count threshold is not expected to trigger. See the dedicated skipped-request plan below.
Failure Rules
Failure rules classify an iteration after commands have finished (none remain scheduled or ongoing); they do not stop running load. Within each rule, metric and expression are independent OR triggers, and any matching rule is sufficient for failure. Termination takes precedence over failure classification.
name: FailureFeaturesPlan
rounds:
- name: FailureRound
numberOfClients: 10
iterations:
- name: CheckoutIteration
mode: R
requestCount: 5
httpRequest:
url: https://httpbin.org/status/500
method: GET
failureRules:
- metric: "ErrorRate > 0.05"
expression: "${Metrics.FailureRound.CheckoutIteration.Duration.TotalTime.P90} > 250"
- metric: "SkippedRequestsCount >= 10"
expression: "${Metrics.FailureRound.CheckoutIteration.Duration.TotalTime.P90} > 250"
- metric: "TotalTime.P90 > 1000"
expression: "${Metrics.FailureRound.CheckoutIteration.Throughput.RPS} > 100"
Expected behavior:
- After commands finish, Rule 1 marks the iteration failed when either
ErrorRate > 0.05or the duration expression is true. - At that same failure-evaluation stage, Rule 2 matches when either
SkippedRequestsCount >= 10or its duration expression is true. - Rule 3 matches when either
TotalTime.P90 > 1000or its throughput expression is true. - This plan does not configure request skipping, so its skipped-count threshold is not expected to trigger. The other conditions can still cause failure.
Retry Rules
Use delayInMs for the retry delay. With strategy: Fixed, it is the delay before every retry. With strategy: Exponential, it is the initial delay, which doubles for each subsequent retry.
strategydefaults toFixed.delayInMsdefaults to100ms when omitted; omitting it does not enable immediate retries.delayInMsmust be greater than zero. Zero-delay retries are not supported; the smallest accepted delay is1ms.maxDelayInMsis an optional cap forExponentialonly and must be at leastdelayInMs.maxRetriesdefaults to1when omitted.
Priority of stopIf and if
Both conditions can be provided together. After each request attempt, stopIf is checked first and takes priority:
stopIf |
if |
Result |
|---|---|---|
true |
Either | Stop retrying; if is not evaluated. |
false or omitted |
true or omitted |
Retry if retries remain. |
false or omitted |
false |
Stop retrying. |
Omitting if behaves as if: true. maxRetries still limits the number of retries after the initial attempt.
For example, this retries HTTP errors except 401, up to three retries. The request using this snippet must capture its response into LastResponse.
retry:
if: ${LastResponse.StatusCode} >= 400
stopIf: ${LastResponse.StatusCode} = 401
maxRetries: 3
strategy: Fixed
delayInMs: 500
If the response is 401, both conditions are true, but stopIf wins and no further retry is made. This stops retries for the current request, not the entire iteration or plan.
Complete retry plan
Capture variables are session-scoped by default, not iteration-scoped. This plan runs iterations sequentially and gives each iteration its own response variable to avoid overwriting another iteration's captured response.
LPS currently rejects session-scoped captures when runInParallel: true. Distinct names do not remove that restriction. Setting makeGlobal: true is not a general workaround for per-request retry conditions: it shares captured values across clients.
name: RetryFeaturesPlan
rounds:
- name: RetryRound
numberOfClients: 1
runInParallel: false
iterations:
- name: ExponentialRetry
mode: R
requestCount: 5
httpRequest:
capture:
to: exponentialResponse
as: Json
makeGlobal: false
url: https://httpbin.org/status/500
method: GET
retry:
if: ${exponentialResponse.StatusCode} >= 500
maxRetries: 3
strategy: Exponential
delayInMs: 100
maxDelayInMs: 2000
- name: FixedRetry
mode: R
requestCount: 5
httpRequest:
capture:
to: fixedResponse
as: Json
makeGlobal: false
url: https://httpbin.org/status/500
method: GET
retry:
if: ${fixedResponse.StatusCode} >= 500
maxRetries: 3
strategy: Fixed
delayInMs: 500
- name: DefaultDelayRetry
mode: R
requestCount: 5
httpRequest:
capture:
to: defaultDelayResponse
as: Json
makeGlobal: false
url: https://httpbin.org/status/500
method: GET
retry:
if: ${defaultDelayResponse.StatusCode} >= 500
maxRetries: 1
Expected behavior:
- ExponentialRetry: valid. Uses exponential backoff with
delayInMs=100, capped bymaxDelayInMs=2000, up to 3 retries. - FixedRetry: valid. Uses fixed delay of 500 ms for up to 3 retries.
- DefaultDelayRetry: valid. Uses the default fixed delay of 100 ms for up to 1 retry.
Retry Validation Scenarios
The following scenarios show retry defaults and explicit delay settings. Each standalone snippet assumes its request captures its response into LastResponse; the full plan above uses distinct response names for its separate iterations.
1) maxRetries only
retry:
if: ${LastResponse.StatusCode} >= 500
maxRetries: 3
Expected behavior:
- Valid configuration.
- Retry mode is fixed-delay with the default 100 ms between retries.
2) maxRetries + delayInMs
retry:
if: ${LastResponse.StatusCode} >= 500
maxRetries: 3
delayInMs: 500
Expected behavior:
- Valid configuration.
- Retry mode is fixed-delay (500 ms between retries).
3) delayInMs only
retry:
if: ${LastResponse.StatusCode} >= 500
delayInMs: 500
Expected behavior:
- Valid configuration.
- Uses the default
maxRetries: 1andstrategy: Fixed, with a 500 ms delay before the retry.
4) exponential backoff (maxRetries + strategy + delayInMs + maxDelayInMs)
retry:
if: ${LastResponse.StatusCode} >= 500
maxRetries: 3
strategy: Exponential
delayInMs: 100
maxDelayInMs: 2000
Expected behavior:
- Valid configuration.
- Retry mode is exponential backoff starting at 100 ms and capped at 2000 ms.
SkippedRequestsCount + expression Scenarios
The preceding plans show how to combine SkippedRequestsCount with expression, but do not generate skipped requests themselves.
To exercise a skipped-count threshold, use request-level httpRequest.skipIf, not iteration-level skipIf (which bypasses the iteration's request execution). This plan schedules 30 requests, each of which is reported as skipped instead of being sent:
name: SkippedRequestsPlan
rounds:
- name: SkippedRound
numberOfClients: 1
iterations:
- name: SkippedIteration
mode: R
requestCount: 30
httpRequest:
url: https://example.com
method: GET
skipIf: "true"
failureRules:
- metric: "SkippedRequestsCount >= 10"
The skipped-count condition is met once the reported count reaches 10; failure evaluation waits until commands finish. Failure classification is checked before the all-skipped classification.
The following are standalone rule snippets. Replace RoundName and IterationName with actual plan names. Termination rules are evaluated during execution; failure rules are evaluated after commands finish.
Current backend limitation: expression-only rules pass validation, but the evaluators still attempt to parse the absent metric when the expression is false (or its termination grace period is pending), which can log an invalid-rule error. This is an evaluator limitation, not invalid expression-only syntax.
Termination rule: expression only (no metric)
terminationRules:
- expression: "${Metrics.RoundName.IterationName.Throughput.RPS} > 50"
Expected behavior:
- Valid configuration.
- With no grace period configured, termination can occur at the next evaluation where the
expressionis true.
Termination rule: valid skipped count + expression
terminationRules:
- metric: "SkippedRequestsCount > 25"
expression: "${Metrics.RoundName.IterationName.Throughput.RPS} > 50"
Expected behavior:
- Valid configuration.
- With no grace period configured, termination can occur at the next evaluation where either condition is true:
SkippedRequestsCount > 25, orexpressionevaluates to true.
Termination rule: invalid skipped count aggregation
terminationRules:
- metric: "SkippedRequestsCount.P95 > 25"
Expected behavior:
- Invalid configuration.
SkippedRequestsCountis a scalar metric and does not support aggregations like.P95.
Failure rule: expression only (no metric)
failureRules:
- expression: "${Metrics.RoundName.IterationName.Duration.TotalTime.P90} > 250"
Expected behavior:
- Valid configuration.
- After commands finish, the iteration is classified as failed if the
expressionevaluates to true at failure evaluation.
Failure rule: valid skipped count + expression
failureRules:
- metric: "SkippedRequestsCount >= 10"
expression: "${Metrics.RoundName.IterationName.Duration.TotalTime.P90} > 250"
Expected behavior:
- Valid configuration.
- After commands finish, the iteration is classified as failed if either condition is true at failure evaluation:
SkippedRequestsCount >= 10, orexpressionevaluates to true.
Failure rule: invalid expression example
failureRules:
- metric: "ErrorRate > 0.05"
expression: "this-is-not-a-valid-expression"
Expected behavior:
- Invalid configuration.
- Rule expressions must be placeholders (start with
$) or comparison-shaped expressions.
What it demonstrates
- optional termination grace periods, applying independently to metric and expression triggers; omission means no added grace delay
expressionconditions on termination and failure rules- skipped-count thresholds expressed directly in the metric field on termination and failure rules
- retry delay strategies: exponential and fixed, with a default delay of 100 ms