Agents And Coordinator

Learn how coordinator and agent nodes split, execute, and merge one clustered LoadStrike run.

What this page helps you do

What this page helps you do

Learn how coordinator and agent nodes split, execute, and merge one clustered LoadStrike run.

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

Cluster topology diagram showing the coordinator, agents, and merged result.
Cluster settings matter because the coordinator, agents, and merged result all belong to the same workload definition.

Guide

Two ways to run cluster mode

EnableLocalDevCluster(true) starts child agents in-process for local development. Distributed mode uses NodeType plus NatsServerUrl so separate coordinator and agent processes can communicate over NATS.

What the coordinator controls

The coordinator sets ClusterId, AgentGroup, AgentsCount, optional coordinator or agent target lists, and ClusterCommandTimeout. It is also the node that produces the final merged report.

What agents need

Agents need NodeType.Agent, the same ClusterId, the same AgentGroup if one is used, and the NATS server URL. They usually do not need a runner key in example docs unless the selected deployment path requires it on that process.

How scenario targeting works

TargetScenarios applies a shared filter, AgentTargetScenarios narrows agent-side work, and CoordinatorTargetScenarios narrows coordinator-side work. Use these lists when different nodes should own different parts of the transaction.

Cluster setup samples

Register the same scenarios on both roles, then use coordinator and agent targeting to decide which role executes which scenario name. Start agents first, then trigger the coordinator.

If you run these examples locally, add a valid runner key before execution starts. Set it with WithRunnerKey("...") or the config key LoadStrike:RunnerKey.

Coordinator + Agent Configuration

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

Coordinator and agent settings

NodeType

Coordinator merges results and assigns work. Agent executes assigned scenarios and returns partial stats.

ClusterId / AgentGroup

Must line up between the participating processes so they join the same run and, optionally, the same agent pool.

AgentsCount

Coordinator expectation for how many agents should participate.

NatsServerUrl

Transport used for distributed coordinator-agent communication.

TargetScenarios / AgentTargetScenarios / CoordinatorTargetScenarios

Scenario filters used when different roles should own different parts of the workload.

ClusterCommandTimeout

Coordinator wait budget for cluster coordination commands and result collection.

EnableLocalDevCluster

Development-only convenience mode that removes the need for separately managed agent processes.

{
  "LoadStrike": {
    "NodeType": "Coordinator",
    "ClusterId": "orders-cluster",
    "AgentGroup": "perf-agents",
    "AgentsCount": 3,
    "RunnerKey": "rkr_your_remote_runner_key",
    "NatsServerUrl": "nats://localhost:4222",
    "TargetScenarios": "http-source,kafka-consumer",
    "AgentTargetScenarios": "kafka-consumer",
    "CoordinatorTargetScenarios": "http-source",
    "ClusterCommandTimeoutMs": 120000,
    "EnableLocalDevCluster": false
  }
}