Version v1.0 · dotnet

Worker Options

Configure worker identity, polling cadence, and throughput behavior.

Worker Options

Worker options control how aggressively each process claims and executes work.

These settings are the primary levers for throughput and load distribution.

Key options

  • WorkerName: unique worker identity for lease ownership and diagnostics.
  • PollInterval / PollIntervalSeconds: base polling cadence.
  • PollJitterEnabled and PollJitterRatio: randomize poll timing to distribute claim pressure. Default: enabled with ratio 0.2.
  • BatchSize (ClaimBatchSize): max runs claimed per poll.
  • MaxConcurrentRuns: max in-flight runs executed concurrently per worker.
  • JobActivation: DI activation model (ScopedPerExecution or RootProvider).

Example

using DurableStack.Core.Options;

builder.Services.AddDurableStackPostgres(connectionString, options =>
{
    options.WorkerName = $"billing-api-{Environment.MachineName}-{Environment.ProcessId}";

    options.PollIntervalSeconds = 5;
    options.PollJitterEnabled = true;
    options.PollJitterRatio = 0.2;

    options.BatchSize = 50;
    options.MaxConcurrentRuns = 10;

    options.JobActivation = DurableStackJobActivationMode.ScopedPerExecution;
});

How to tune

  • Increase MaxConcurrentRuns before aggressively increasing BatchSize.
  • Keep poll jitter enabled in multi-worker deployments.
  • Use unique, stable worker names per process instance.
  • Keep ScopedPerExecution unless you intentionally avoid scoped dependencies.

Common pitfalls

  • Reusing the same WorkerName across containers.
  • Setting very low poll intervals without jitter in large clusters.
  • Setting high concurrency without validating database and dependency capacity.

AddDurableStackWithJitter(...) is deprecated in v1.0 because poll jitter is already enabled by default.