What Is A Transaction?
A transaction in LoadStrike is the full workflow you care about, not just one request. Read this page first if your workload crosses systems.
Guide
Definition
In LoadStrike, a transaction is the business workflow that matters to the team. It might start at an API edge, continue through Kafka or another transport, and finish only when the downstream work proves the outcome really happened.
Why It Matters
A fast first request does not always mean the system stayed healthy. Transaction testing keeps the full workflow together so you can see whether queues, workers, follow-on services, and browser steps still complete correctly under load.
How LoadStrike Models It
You model the workflow as a scenario, name the important operations as steps, and add source and destination endpoints when the path crosses systems. LoadStrike then correlates those events and reports the whole outcome as one performance story.
Feature Usage Samples
Licensing note: every runnable sample still needs a valid runner key. Set it with WithRunnerKey("...") or the config key LoadStrike:RunnerKey before you run the test.
Transaction Example
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 () =>
{
var payload = new
{
orderId = $"ord-{context.InvocationNumber}",
amount = 49.95m
};
using var response = await httpClient.PostAsJsonAsync("/orders", payload);
return response.IsSuccessStatusCode
? LoadStrikeResponse.Ok<string>(statusCode: ((int)response.StatusCode).ToString())
: LoadStrikeResponse.Fail<string>(
statusCode: ((int)response.StatusCode).ToString(),
message: "Order submission failed");
});
return step.AsReply();
})
.WithLoadSimulations(
LoadStrikeSimulation.Inject(10, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(20))
);
LoadStrikeRunner.RegisterScenarios(scenario)
.WithRunnerKey("rkl_your_local_runner_key")
.Run();
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 -> 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.send(request, HttpResponse.BodyHandlers.ofString());
return response.statusCode() < 400
? LoadStrikeResponse.ok(Integer.toString(response.statusCode()))
: LoadStrikeResponse.fail(Integer.toString(response.statusCode()), "Order submission failed");
}).asReply())
.withLoadSimulations(LoadStrikeSimulation.inject(10, 1d, 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):
def run_step():
payload = {
"orderId": f"ord-{context.invocation_number}",
"amount": 49.95,
}
response = requests.post("https://api.example.com/orders", json=payload, timeout=15)
if response.ok:
return LoadStrikeResponse.ok(str(response.status_code))
return LoadStrikeResponse.fail(str(response.status_code), "Order submission failed")
return LoadStrikeStep.run("POST /orders", context, run_step).as_reply()
scenario = (
LoadStrikeScenario.create("submit-orders", submit_orders)
.with_load_simulations(LoadStrikeSimulation.inject(10, 1, 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) => {
return LoadStrikeStep.run("POST /orders", context, async () => {
const payload = {
orderId: `ord-${context.invocationNumber}`,
amount: 49.95
};
const response = await fetch("https://api.example.com/orders", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify(payload)
});
return response.ok
? LoadStrikeResponse.ok(String(response.status))
: LoadStrikeResponse.fail(String(response.status), "Order submission failed");
});
})
.withLoadSimulations(LoadStrikeSimulation.inject(10, 1, 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) => {
return LoadStrikeStep.run("POST /orders", context, async () => {
const payload = {
orderId: `ord-${context.invocationNumber}`,
amount: 49.95
};
const response = await fetch("https://api.example.com/orders", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify(payload)
});
return response.ok
? LoadStrikeResponse.ok(String(response.status))
: LoadStrikeResponse.fail(String(response.status), "Order submission failed");
});
})
.withLoadSimulations(LoadStrikeSimulation.inject(10, 1, 20));
await LoadStrikeRunner
.registerScenarios(scenario)
.withRunnerKey("rkl_your_local_runner_key")
.run();
})();
Transaction parts
The scenario name should describe the workflow being validated, not only the endpoint being called.
Use a named step for the operation that matters to the transaction so reports stay readable.
Attach the concurrency or rate pattern that represents the real workload you want to simulate.
When the workflow crosses systems, attach source and destination definitions so the runtime can measure completion end to end.