Dynamic Workloads
Model changing traffic patterns using staged simulations and distribution controls.
Adaptive Traffic Shape
Use InjectRandom and Ramping* simulations to model variable traffic and progressive scaling instead of flat load only.
Scenario Weighting
Use WithWeight per scenario to bias assignment and throughput share when distributing scenarios across agents.
Runtime Control
Use context.StopScenario or context.StopCurrentTest from scenario code to stop execution based on dynamic runtime signals.
Feature Usage Samples
How to use snippets for Dynamic Workloads.
Switch between C#, Java, Python, TypeScript, and JavaScript to see the native SDK shape for this sample.
Licensing note: every runnable sample requires a valid runner key via WithRunnerKey("...") or config key LoadStrike:RunnerKey.
Dynamic Workload
var scenario = LoadStrikeScenario.Create("dynamic", context =>
{
if (context.InvocationNumber >= 500)
{
context.StopScenario("dynamic", "enough-load");
}
return Task.FromResult(LoadStrikeResponse.Ok());
})
.WithLoadSimulations(
LoadStrikeSimulation.InjectRandom(5, 15, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(20)),
LoadStrikeSimulation.RampingConstant(8, TimeSpan.FromSeconds(20))
);
import com.loadstrike.runtime.LoadStrikeRuntime.LoadStrikeResponse;
import com.loadstrike.runtime.LoadStrikeRuntime.LoadStrikeScenario;
import com.loadstrike.runtime.LoadStrikeRuntime.LoadStrikeSimulation;
var scenario = LoadStrikeScenario.create("dynamic", context -> {
if (context.InvocationNumber >= 500) {
context.StopScenario("dynamic", "enough-load");
}
return LoadStrikeResponse.ok();
})
.withLoadSimulations(
LoadStrikeSimulation.injectRandom(5, 15, 1d, 20d),
LoadStrikeSimulation.rampingConstant(8, 20d));
from loadstrike_sdk import LoadStrikeResponse, LoadStrikeScenario, LoadStrikeSimulation
scenario = (
LoadStrikeScenario.create(
"dynamic",
lambda context: (
context.stop_scenario("dynamic", "enough-load")
if context.invocation_number >= 500
else None,
LoadStrikeResponse.ok(),
)[-1],
)
.with_load_simulations(
LoadStrikeSimulation.inject_random(5, 15, 1, 20),
LoadStrikeSimulation.ramping_constant(8, 20),
)
)
import {
LoadStrikeResponse,
LoadStrikeScenario,
LoadStrikeSimulation
} from "@loadstrike/loadstrike-sdk";
const scenario = LoadStrikeScenario
.create("dynamic", async (context) => {
if (context.invocationNumber >= 500) {
context.stopScenario("dynamic", "enough-load");
}
return LoadStrikeResponse.ok();
})
.withLoadSimulations(
LoadStrikeSimulation.injectRandom(5, 15, 1, 20),
LoadStrikeSimulation.rampingConstant(8, 20)
);
const {
LoadStrikeResponse,
LoadStrikeScenario,
LoadStrikeSimulation
} = require("@loadstrike/loadstrike-sdk");
const scenario = LoadStrikeScenario
.create("dynamic", async (context) => {
if (context.invocationNumber >= 500) {
context.stopScenario("dynamic", "enough-load");
}
return LoadStrikeResponse.ok();
})
.withLoadSimulations(
LoadStrikeSimulation.injectRandom(5, 15, 1, 20),
LoadStrikeSimulation.rampingConstant(8, 20)
);
Pattern
Chain multiple simulations in order to represent ramp-up, spikes, steady traffic, and cooldown in one scenario.
Choose InjectRandom when the rate should vary from interval to interval instead of staying flat.
Use scenario context stop helpers when runtime conditions should end one scenario or the whole run dynamically.