Cluster Overview

Cluster mode lets one LoadStrike run spread across multiple nodes. Use it when a single machine is not enough or when topology matters.

What this page helps you do

What this page helps you do

Understand when to move from one machine to coordinator-and-agent execution and what each node is responsible for.

Who this is for

Teams scaling beyond a single host or modeling separated source and destination roles.

Prerequisites

  • A working single-node scenario
  • A topology that benefits from multiple nodes or roles

By the end

A clear cluster mental model and the fields that must align across coordinator and agents.

Choose this path when

Move to cluster mode when one machine is not enough, when browser sessions need to be spread out, or when topology itself changes the result you care about.

Visual guide

Topology diagram showing one coordinator, multiple agents, NATS, and a merged final report.
The coordinator assigns work, agents execute it, and LoadStrike merges the node results into one report.

Guide

What cluster mode does

Cluster mode lets one coordinator orchestrate the run while one or more agents execute the assigned scenarios. The coordinator merges every node result into one final report.

When to use it

Use cluster mode when one machine is not enough for the desired load, when browser workloads need to be spread out, or when you want to model separate source and destination roles across nodes.

What makes nodes join the same run

ClusterId must match across the coordinator and agents. AgentGroup is optional but useful when one coordinator should target a specific pool of agents.

What the coordinator still needs

The coordinator still needs the registered scenarios, the expected AgentsCount, the node role, a valid runner key, and a transport for coordinator-agent communication such as NATS or the local-dev cluster mode.

Cluster setup samples

This sample shows the full distributed flow: define one shared clusterId, start the agent processes with NodeType.Agent, then start one coordinator with the same clusterId and the expected AgentsCount.

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 Setup

using LoadStrike;

var clusterId = "orders-cluster";
var agentGroup = "perf-agents";
var natsUrl = "nats://nats.example.internal:4222";

var submitOrdersScenario = LoadStrikeScenario.Create(
        "submit-orders",
        _ => Task.FromResult(LoadStrikeResponse.Ok(statusCode: "200")))
    .WithLoadSimulations(LoadStrikeSimulation.IterationsForConstant(1, 2));

var waitForCompletionScenario = LoadStrikeScenario.Create(
        "wait-for-completion",
        _ => Task.FromResult(LoadStrikeResponse.Ok(statusCode: "200")))
    .WithLoadSimulations(LoadStrikeSimulation.IterationsForConstant(1, 2));

var agentContext = LoadStrikeRunner
    .RegisterScenarios(submitOrdersScenario, waitForCompletionScenario)
    .WithNodeType(LoadStrikeNodeType.Agent)
    .WithClusterId(clusterId)
    .WithAgentGroup(agentGroup)
    .WithAgentTargetScenarios("wait-for-completion")
    .WithNatsServerUrl(natsUrl);

// Start this on each agent machine or process first.
agentContext.Run();

var coordinatorContext = LoadStrikeRunner
    .RegisterScenarios(submitOrdersScenario, waitForCompletionScenario)
    .WithNodeType(LoadStrikeNodeType.Coordinator)
    .WithClusterId(clusterId)
    .WithAgentGroup(agentGroup)
    .WithAgentsCount(2)
    .WithCoordinatorTargetScenarios("submit-orders")
    .WithAgentTargetScenarios("wait-for-completion")
    .WithNatsServerUrl(natsUrl)
    .WithRunnerKey("rkr_your_remote_runner_key");

// Start this once after the agents are listening.
coordinatorContext.Run();

Cluster role fields

WithNodeType(nodeType)

Selects SingleNode, Coordinator, or Agent behavior.

WithClusterId(clusterId)

Required shared cluster identity across coordinator and agents.

WithAgentGroup(agentGroup)

Optional grouping field that lets a coordinator target a specific agent pool.

WithAgentsCount(agentsCount)

Coordinator-only expected agent count. The value must be greater than zero.

WithNatsServerUrl(natsUrl)

Required for distributed NATS-backed cluster mode.

EnableLocalDevCluster(enable)

Local-development mode that starts child agents in-process instead of using external NATS agents.