Node Targeting
Node targeting decides which scenarios stay on the coordinator and which are pushed to agents in clustered runs.
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
Node targeting decides which scenarios stay on the coordinator and which are pushed to agents in clustered runs.
Who this is for
Teams moving from one machine to coordinator-and-agent execution or tighter workload targeting.
Prerequisites
- A scenario that already works in a single-node run
By the end
A clearer cluster topology and the fields that must line up across nodes.
Use this page when
Use this page when execution topology, partitioning, or targeting changes how the run should be distributed.
Visual guide
Guide
What node targeting solves
Node targeting lets you run only the scenarios that belong on a given role or node group. This is useful when one set of nodes should publish traffic and another should consume or observe downstream activity.
Available target lists
Use TargetScenarios for a global filter, AgentTargetScenarios for agent-only filters, and CoordinatorTargetScenarios for coordinator-only filters. The runtime compares scenario names using the names you registered in code.
When to keep it simple
If every node can run every scenario, skip targeting and let the coordinator distribute the workload normally. Add targeting only when you need explicit workload ownership.
Cluster setup samples
The sample below keeps both scenario definitions in both processes, then uses CoordinatorTargetScenarios and AgentTargetScenarios to route the right scenario names to the right role.
If you run these examples locally, add a valid runner key before execution starts. Set it with WithRunnerKey("...") or the config key LoadStrike:RunnerKey.
Target Scenarios Per Node
using LoadStrike;
var clusterId = "orders-cluster";
var natsUrl = "nats://nats.example.internal:4222";
var publishOrdersScenario = LoadStrikeScenario.Create(
"publish-orders",
_ => Task.FromResult(LoadStrikeResponse.Ok(statusCode: "202")))
.WithLoadSimulations(LoadStrikeSimulation.IterationsForConstant(1, 2));
var observeCompletionScenario = LoadStrikeScenario.Create(
"observe-completion",
_ => Task.FromResult(LoadStrikeResponse.Ok(statusCode: "200")))
.WithLoadSimulations(LoadStrikeSimulation.IterationsForConstant(1, 2));
var agentContext = LoadStrikeRunner
.RegisterScenarios(publishOrdersScenario, observeCompletionScenario)
.WithNodeType(LoadStrikeNodeType.Agent)
.WithClusterId(clusterId)
.WithAgentTargetScenarios("observe-completion")
.WithNatsServerUrl(natsUrl);
// Each agent process listens for the scenario names assigned to agents.
agentContext.Run();
var coordinatorContext = LoadStrikeRunner
.RegisterScenarios(publishOrdersScenario, observeCompletionScenario)
.WithNodeType(LoadStrikeNodeType.Coordinator)
.WithClusterId(clusterId)
.WithAgentsCount(2)
.WithCoordinatorTargetScenarios("publish-orders")
.WithAgentTargetScenarios("observe-completion")
.WithNatsServerUrl(natsUrl)
.WithRunnerKey("rkr_your_remote_runner_key");
// The coordinator triggers only its own scenarios and routes agent work by scenario name.
coordinatorContext.Run();
package main
import loadstrike "loadstrike.com/sdk/go"
func main() {
loadstrike.RegisterScenarios(loadstrike.Empty("cluster-routing")).
WithClusterId("cluster-orders-prod").
WithAgentGroup("brokers").
WithNatsServerUrl("nats://127.0.0.1:4222").
WithTargetScenarios("source", "destination").
WithAgentTargetScenarios("destination").
WithCoordinatorTargetScenarios("source").
Run()
}
import com.loadstrike.runtime.LoadStrikeRuntime.LoadStrikeResponse;
import com.loadstrike.runtime.LoadStrikeRuntime.LoadStrikeNodeType;
import com.loadstrike.runtime.LoadStrikeRuntime.LoadStrikeRunner;
import com.loadstrike.runtime.LoadStrikeRuntime.LoadStrikeScenario;
import com.loadstrike.runtime.LoadStrikeRuntime.LoadStrikeSimulation;
String clusterId = "orders-cluster";
String natsUrl = "nats://nats.example.internal:4222";
var publishOrdersScenario = LoadStrikeScenario
.create("publish-orders", ignoredContext -> LoadStrikeResponse.ok("202"))
.withLoadSimulations(LoadStrikeSimulation.iterationsForConstant(1, 2));
var observeCompletionScenario = LoadStrikeScenario
.create("observe-completion", ignoredContext -> LoadStrikeResponse.ok("200"))
.withLoadSimulations(LoadStrikeSimulation.iterationsForConstant(1, 2));
var agentRunner = LoadStrikeRunner
.registerScenarios(publishOrdersScenario, observeCompletionScenario)
.withNodeType(LoadStrikeNodeType.Agent)
.buildContext()
.withClusterId(clusterId)
.withAgentTargetScenarios("observe-completion")
.withNatsServerUrl(natsUrl);
// Each agent process listens for the scenario names assigned to agents.
agentRunner.run();
var coordinatorRunner = LoadStrikeRunner
.registerScenarios(publishOrdersScenario, observeCompletionScenario)
.withNodeType(LoadStrikeNodeType.Coordinator)
.buildContext()
.withClusterId(clusterId)
.withAgentsCount(2)
.withCoordinatorTargetScenarios("publish-orders")
.withAgentTargetScenarios("observe-completion")
.withNatsServerUrl(natsUrl)
.withRunnerKey("rkr_your_remote_runner_key");
// The coordinator triggers only its own scenarios and routes agent work by scenario name.
coordinatorRunner.run();
from loadstrike_sdk import LoadStrikeResponse, LoadStrikeRunner, LoadStrikeScenario, LoadStrikeSimulation
cluster_id = "orders-cluster"
nats_url = "nats://nats.example.internal:4222"
publish_orders_scenario = (
LoadStrikeScenario.create("publish-orders", lambda _: LoadStrikeResponse.ok("202"))
.with_load_simulations(LoadStrikeSimulation.iterations_for_constant(1, 2))
)
observe_completion_scenario = (
LoadStrikeScenario.create("observe-completion", lambda _: LoadStrikeResponse.ok("200"))
.with_load_simulations(LoadStrikeSimulation.iterations_for_constant(1, 2))
)
agent_runner = (
LoadStrikeRunner.register_scenarios(publish_orders_scenario, observe_completion_scenario)
.with_node_type("Agent")
.with_cluster_id(cluster_id)
.with_agent_target_scenarios("observe-completion")
.with_nats_server_url(nats_url)
)
# Each agent process listens for the scenario names assigned to agents.
agent_runner.run()
coordinator_runner = (
LoadStrikeRunner.register_scenarios(publish_orders_scenario, observe_completion_scenario)
.with_node_type("Coordinator")
.with_cluster_id(cluster_id)
.with_agents_count(2)
.with_coordinator_target_scenarios("publish-orders")
.with_agent_target_scenarios("observe-completion")
.with_nats_server_url(nats_url)
.with_runner_key("rkr_your_remote_runner_key")
)
# The coordinator triggers only its own scenarios and routes agent work by scenario name.
coordinator_runner.run()
import {
LoadStrikeResponse,
LoadStrikeRunner,
LoadStrikeScenario,
LoadStrikeSimulation
} from "@loadstrike/loadstrike-sdk";
const clusterId = "orders-cluster";
const natsUrl = "nats://nats.example.internal:4222";
const publishOrdersScenario = LoadStrikeScenario
.create("publish-orders", async () => LoadStrikeResponse.ok("202"))
.withLoadSimulations(LoadStrikeSimulation.iterationsForConstant(1, 2));
const observeCompletionScenario = LoadStrikeScenario
.create("observe-completion", async () => LoadStrikeResponse.ok("200"))
.withLoadSimulations(LoadStrikeSimulation.iterationsForConstant(1, 2));
const agentRunner = LoadStrikeRunner
.registerScenarios(publishOrdersScenario, observeCompletionScenario)
.withNodeType("Agent")
.withClusterId(clusterId)
.withAgentTargetScenarios("observe-completion")
.withNatsServerUrl(natsUrl);
// Each agent process listens for the scenario names assigned to agents.
await agentRunner.run();
const coordinatorRunner = LoadStrikeRunner
.registerScenarios(publishOrdersScenario, observeCompletionScenario)
.withNodeType("Coordinator")
.withClusterId(clusterId)
.withAgentsCount(2)
.withCoordinatorTargetScenarios("publish-orders")
.withAgentTargetScenarios("observe-completion")
.withNatsServerUrl(natsUrl)
.withRunnerKey("rkr_your_remote_runner_key");
// The coordinator triggers only its own scenarios and routes agent work by scenario name.
await coordinatorRunner.run();
const {
LoadStrikeResponse,
LoadStrikeRunner,
LoadStrikeScenario,
LoadStrikeSimulation
} = require("@loadstrike/loadstrike-sdk");
(async () => {
const clusterId = "orders-cluster";
const natsUrl = "nats://nats.example.internal:4222";
const publishOrdersScenario = LoadStrikeScenario
.create("publish-orders", async () => LoadStrikeResponse.ok("202"))
.withLoadSimulations(LoadStrikeSimulation.iterationsForConstant(1, 2));
const observeCompletionScenario = LoadStrikeScenario
.create("observe-completion", async () => LoadStrikeResponse.ok("200"))
.withLoadSimulations(LoadStrikeSimulation.iterationsForConstant(1, 2));
const agentRunner = LoadStrikeRunner
.registerScenarios(publishOrdersScenario, observeCompletionScenario)
.withNodeType("Agent")
.withClusterId(clusterId)
.withAgentTargetScenarios("observe-completion")
.withNatsServerUrl(natsUrl);
// Each agent process listens for the scenario names assigned to agents.
await agentRunner.run();
const coordinatorRunner = LoadStrikeRunner
.registerScenarios(publishOrdersScenario, observeCompletionScenario)
.withNodeType("Coordinator")
.withClusterId(clusterId)
.withAgentsCount(2)
.withCoordinatorTargetScenarios("publish-orders")
.withAgentTargetScenarios("observe-completion")
.withNatsServerUrl(natsUrl)
.withRunnerKey("rkr_your_remote_runner_key");
// The coordinator triggers only its own scenarios and routes agent work by scenario name.
await coordinatorRunner.run();
})();
Node targeting fields
Applies a global scenario-name filter to the current run context.
Applies an additional scenario-name filter for agent-side work.
Applies an additional scenario-name filter for coordinator-side work.
Filters are matched against the registered scenario names, so they must use the exact names defined in code.