Load Simulation
Load simulations describe how traffic should arrive over time. Use them to model the shape of the workload instead of only its peak.
Matching docs
Search across docs titles, summaries, groups, and section headings.
Use Up and Down Arrow to move through results, then press Enter to open the active page.
No indexed docs matched that search. Try a broader term or open the docs hub.
What this page helps you do
What this page helps you do
Load simulations describe how traffic should arrive over time. Use them to model the shape of the workload instead of only its peak.
Who this is for
Engineers writing or reviewing scenario code in one of the supported SDKs.
Prerequisites
- A scenario or runtime surface you want to wire correctly in code
By the end
The exact SDK surface you need for this part of the runtime.
Use this page when
Use this reference when you already know the workflow and need the exact Load Simulation API surface in code.
Visual guide
Guide
Time-Based Simulations
Use duration-based simulations when you want traffic to run for a period of time. Inject(rate, interval, during), InjectRandom(minRate, maxRate, interval, during), RampingInject(rate, interval, during), KeepConstant(copies, during), RampingConstant(copies, during), and Pause(during) all fit that model.
Iteration-Based Simulations
Use iteration-based simulations when you care about a fixed amount of work rather than a fixed duration. IterationsForInject(rate, interval, iterations) and IterationsForConstant(copies, iterations) stop after the configured number of execution cycles.
Parameter Fields
rate, minRate, and maxRate control request emission intensity. copies controls concurrent virtual users. interval controls pacing, during controls time, and iterations controls total execution cycles. Helper APIs also expose IsInject, IsInjectRandom, IsIterationsForInject, IsIterationsForConstant, and related flags plus string formatting helpers on returned simulation definitions.
Runtime Stop Control
Load shape is not the only stop signal. Use context.StopScenario(...) when one scenario should end early after the runtime has observed enough data, or context.StopCurrentTest(...) when the whole run should stop because a critical runtime condition has been reached.
Composition
Attach multiple simulations in order with WithLoadSimulations when one scenario needs warm-up, ramp-up, steady-state, and cooldown phases in a single definition.
SDK reference samples
Use these SDK samples to compare how Load Simulation is exposed across the supported languages before you wire it into a full scenario.
If you run these examples locally, add a valid runner key before execution starts. Set it with WithRunnerKey("...") or the config key LoadStrike:RunnerKey.
Load Simulations
using LoadStrike;
var httpClient = new HttpClient
{
BaseAddress = new Uri("https://api.example.com")
};
var scenario = LoadStrikeScenario.Create("submit-orders", async context =>
{
var step = await LoadStrikeStep.Run<string>("POST /orders", context, async () =>
{
using var response = await httpClient.PostAsJsonAsync("/orders", new
{
orderId = $"ord-{context.InvocationNumber}",
amount = 49.95m
});
return response.IsSuccessStatusCode
? LoadStrikeResponse.Ok<string>(statusCode: ((int)response.StatusCode).ToString())
: LoadStrikeResponse.Fail<string>(statusCode: ((int)response.StatusCode).ToString());
});
return step.AsReply();
})
.WithLoadSimulations(
LoadStrikeSimulation.Inject(5, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(20)),
LoadStrikeSimulation.RampingInject(20, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(20)),
LoadStrikeSimulation.KeepConstant(8, TimeSpan.FromSeconds(20))
);
LoadStrikeRunner.RegisterScenarios(scenario)
.WithRunnerKey("rkl_your_local_runner_key")
.Run();
package main
import loadstrike "loadstrike.com/sdk/go"
var simulations = []loadstrike.LoadStrikeLoadSimulation{
loadstrike.LoadStrikeSimulation.Inject(10, loadstrike.DurationFromSeconds(1), loadstrike.DurationFromSeconds(20)),
loadstrike.LoadStrikeSimulation.InjectRandom(5, 15, loadstrike.DurationFromSeconds(1), loadstrike.DurationFromSeconds(20)),
loadstrike.LoadStrikeSimulation.RampingInject(20, loadstrike.DurationFromSeconds(1), loadstrike.DurationFromSeconds(20)),
loadstrike.LoadStrikeSimulation.IterationsForInject(10, loadstrike.DurationFromSeconds(1), 40),
loadstrike.LoadStrikeSimulation.KeepConstant(5, loadstrike.DurationFromSeconds(20)),
loadstrike.LoadStrikeSimulation.Pause(loadstrike.DurationFromSeconds(3)),
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import com.loadstrike.runtime.LoadStrikeRuntime.LoadStrikeResponse;
import com.loadstrike.runtime.LoadStrikeRuntime.LoadStrikeRunner;
import com.loadstrike.runtime.LoadStrikeRuntime.LoadStrikeScenario;
import com.loadstrike.runtime.LoadStrikeRuntime.LoadStrikeSimulation;
import com.loadstrike.runtime.LoadStrikeRuntime.LoadStrikeStep;
var client = HttpClient.newHttpClient();
var scenario = LoadStrikeScenario.create("submit-orders", context -> {
var step = LoadStrikeStep.run("POST /orders", context, () -> {
String body = "{\"orderId\":\"ord-" + context.invocationNumber + "\",\"amount\":49.95}";
var request = HttpRequest.newBuilder(URI.create("https://api.example.com/orders"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
var response = client.sendAsync(request, HttpResponse.BodyHandlers.ofString()).join();
return response.statusCode() < 400
? LoadStrikeResponse.ok(Integer.toString(response.statusCode()))
: LoadStrikeResponse.fail(Integer.toString(response.statusCode()));
});
return step.asReply();
})
.withLoadSimulations(
LoadStrikeSimulation.inject(5, 1d, 20d),
LoadStrikeSimulation.rampingInject(20, 1d, 20d),
LoadStrikeSimulation.keepConstant(8, 20d)
);
LoadStrikeRunner
.registerScenarios(scenario)
.withRunnerKey("rkl_your_local_runner_key")
.run();
import requests
from loadstrike_sdk import (
LoadStrikeResponse,
LoadStrikeRunner,
LoadStrikeScenario,
LoadStrikeSimulation,
LoadStrikeStep,
)
def submit_orders(context):
step = LoadStrikeStep.run(
"POST /orders",
context,
lambda: (
lambda response: LoadStrikeResponse.ok(str(response.status_code))
if response.ok
else LoadStrikeResponse.fail(str(response.status_code))
)(
requests.post(
"https://api.example.com/orders",
json={"orderId": f"ord-{context.invocation_number}", "amount": 49.95},
timeout=15,
)
),
)
return step.as_reply()
scenario = (
LoadStrikeScenario.create("submit-orders", submit_orders)
.with_load_simulations(
LoadStrikeSimulation.inject(5, 1, 20),
LoadStrikeSimulation.ramping_inject(20, 1, 20),
LoadStrikeSimulation.keep_constant(8, 20),
)
)
LoadStrikeRunner.register_scenarios(scenario) \
.with_runner_key("rkl_your_local_runner_key") \
.run()
import {
LoadStrikeResponse,
LoadStrikeRunner,
LoadStrikeScenario,
LoadStrikeSimulation,
LoadStrikeStep
} from "@loadstrike/loadstrike-sdk";
const scenario = LoadStrikeScenario.create("submit-orders", async (context) => {
const step = await LoadStrikeStep.run("POST /orders", context, async () => {
const response = await fetch("https://api.example.com/orders", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({
orderId: `ord-${context.invocationNumber}`,
amount: 49.95
})
});
return response.ok
? LoadStrikeResponse.ok(String(response.status))
: LoadStrikeResponse.fail(String(response.status));
});
return step.asReply();
}).withLoadSimulations(
LoadStrikeSimulation.inject(5, 1, 20),
LoadStrikeSimulation.rampingInject(20, 1, 20),
LoadStrikeSimulation.keepConstant(8, 20)
);
await LoadStrikeRunner
.registerScenarios(scenario)
.withRunnerKey("rkl_your_local_runner_key")
.run();
const {
LoadStrikeResponse,
LoadStrikeRunner,
LoadStrikeScenario,
LoadStrikeSimulation,
LoadStrikeStep
} = require("@loadstrike/loadstrike-sdk");
(async () => {
const scenario = LoadStrikeScenario.create("submit-orders", async (context) => {
const step = await LoadStrikeStep.run("POST /orders", context, async () => {
const response = await fetch("https://api.example.com/orders", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({
orderId: `ord-${context.invocationNumber}`,
amount: 49.95
})
});
return response.ok
? LoadStrikeResponse.ok(String(response.status))
: LoadStrikeResponse.fail(String(response.status));
});
return step.asReply();
}).withLoadSimulations(
LoadStrikeSimulation.inject(5, 1, 20),
LoadStrikeSimulation.rampingInject(20, 1, 20),
LoadStrikeSimulation.keepConstant(8, 20)
);
await LoadStrikeRunner
.registerScenarios(scenario)
.withRunnerKey("rkl_your_local_runner_key")
.run();
})();
Supported Simulations
Emit requests at a fixed rate per interval for a fixed duration.
Vary the request rate between a minimum and maximum value each interval to simulate uneven live traffic.
Increase the request rate progressively over time instead of keeping it flat from the start.
Run a fixed number of concurrent copies for the requested duration.
Increase the number of concurrent copies gradually until the target steady-state concurrency is reached.
Insert a quiet gap between simulation phases without ending the scenario definition.
Run an inject-style rate pattern for a fixed number of iterations instead of a time window.
Run a fixed concurrency pattern for a fixed number of iterations instead of a duration.
Use runtime stop helpers when the workload should end because the scenario observed enough evidence or because the whole test must stop early for a critical condition.
Choose rate-based simulations when you care about requests per interval, and copy-based simulations when you care about concurrent workload copies.