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.

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

Sequence diagram showing how a LoadStrike workflow moves from setup to report output.
This page fits into the same setup, run, correlate, and report flow as the rest of the public LoadStrike runtime.

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();

Supported Simulations

Inject

Emit requests at a fixed rate per interval for a fixed duration.

InjectRandom

Vary the request rate between a minimum and maximum value each interval to simulate uneven live traffic.

RampingInject

Increase the request rate progressively over time instead of keeping it flat from the start.

KeepConstant

Run a fixed number of concurrent copies for the requested duration.

RampingConstant

Increase the number of concurrent copies gradually until the target steady-state concurrency is reached.

Pause

Insert a quiet gap between simulation phases without ending the scenario definition.

IterationsForInject

Run an inject-style rate pattern for a fixed number of iterations instead of a time window.

IterationsForConstant

Run a fixed concurrency pattern for a fixed number of iterations instead of a duration.

context.StopScenario(...) / context.StopCurrentTest(...)

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.