Data Partition

Partition datasets across agents to avoid overlap and preserve coverage.

Partition Strategy

Each node can operate on an assigned shard of data for deterministic execution.

Feature Usage Samples

How to use snippets for Data Partition.

Switch between C#, Java, Python, TypeScript, and JavaScript to see the native SDK shape for this sample.

Licensing note: every runnable sample requires a valid runner key via WithRunnerKey("...") or config key LoadStrike:RunnerKey.

Partition Test Data by ScenarioPartition

var allUsers = Enumerable.Range(1, 10000).Select(i => $"user-{i}").ToArray();
var partitions = new ConcurrentDictionary<string, string[]>();

var scenario = LoadStrikeScenario.Create("partitioned-users", context =>
    {
        var shard = partitions[context.ScenarioInfo.InstanceId];
        var userId = shard[context.Random.Next(shard.Length)];
        return Task.FromResult(LoadStrikeResponse.Ok(message: userId));
    })
    .WithInit(init =>
    {
        var p = init.ScenarioPartition;
        partitions[init.ScenarioInfo.InstanceId] = allUsers.Where((_, i) => i % p.Count == p.Number).ToArray();
        return Task.CompletedTask;
    });

Partition Formula

partition.Count

Tells each node how many total shards exist for the current run.

partition.Number

Tells the current node which shard number it owns.

Modulo sharding

Uses a stable modulo rule so each item lands on exactly one partition without overlap.

shard(i) => i % partition.Count == partition.Number