Skip to main content

Data Partition

Usually, working in the cluster mode requires handling data by partitions (key ranges). NBomber provides built-in functionality for this called Scenario Auto Partitioning.

Scenario Auto Partitioning

When you run a Scenario in the cluster, NBomber will:

  1. Get all agents that run particular scenarios.
  2. Automatically assign a scenario partition number to each Agent.

You can read ScenarioPartition on the Scenario Init phase, and then, based on the number you get, you can derive what key ranges should be loaded.

Scenario
.Create("my-scenario", async context => { ... }
.WithInit(context =>
{
// based on the number you get, you can derive what key ranges should be loaded.
var partitionNumber = context.ScenarioPartition.Number;

// Count: returns overall scenario partition count across the cluster.
var partitionCount = context.ScenarioPartition.Count;
})