Skip to content

Commit 7b26e59

Browse files
committed
Refactored concurrency settings into a separate options class.
1 parent 39bda34 commit 7b26e59

File tree

2 files changed

+32
-14
lines changed

2 files changed

+32
-14
lines changed

src/Worker/Core/DurableTaskWorkerOptions.cs

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,14 @@ public DataConverter DataConverter
8484
public TimeSpan MaximumTimerInterval { get; set; } = TimeSpan.FromDays(3);
8585

8686
/// <summary>
87-
/// Gets or sets the maximum number of concurrent activity work items that can be processed by the worker.
87+
/// Gets options for the Durable Task worker concurrency.
8888
/// </summary>
89-
public int MaximumConcurrentActivityWorkItems { get; set; } = 100 * Environment.ProcessorCount;
90-
91-
/// <summary>
92-
/// Gets or sets the maximum number of concurrent orchestration work items that can be processed by the worker.
93-
/// </summary>
94-
public int MaximumConcurrentOrchestrationWorkItems { get; set; } = 100 * Environment.ProcessorCount;
95-
96-
/// <summary>
97-
/// Gets or sets the maximum number of concurrent entity work items that can be processed by the worker.
98-
/// </summary>
99-
public int MaximumConcurrentEntityWorkItems { get; set; } = 100 * Environment.ProcessorCount;
89+
/// <remarks>
90+
/// Worker concurrency options control how many work items of a particular type (e.g., orchestration, activity,
91+
/// or entity) can be processed concurrently by the worker. It is recommended to set these values based on the
92+
/// expected workload and the resources available on the machine running the worker.
93+
/// </remarks>
94+
public ConcurrencyOptions Concurrency { get; } = new();
10095

10196
/// <summary>
10297
/// Gets a value indicating whether <see cref="DataConverter" /> was explicitly set or not.
@@ -123,4 +118,25 @@ internal void ApplyTo(DurableTaskWorkerOptions other)
123118
other.EnableEntitySupport = this.EnableEntitySupport;
124119
}
125120
}
121+
122+
/// <summary>
123+
/// Options for the Durable Task worker concurrency.
124+
/// </summary>
125+
public class ConcurrencyOptions
126+
{
127+
/// <summary>
128+
/// Gets or sets the maximum number of concurrent activity work items that can be processed by the worker.
129+
/// </summary>
130+
public int MaximumConcurrentActivityWorkItems { get; set; } = 100 * Environment.ProcessorCount;
131+
132+
/// <summary>
133+
/// Gets or sets the maximum number of concurrent orchestration work items that can be processed by the worker.
134+
/// </summary>
135+
public int MaximumConcurrentOrchestrationWorkItems { get; set; } = 100 * Environment.ProcessorCount;
136+
137+
/// <summary>
138+
/// Gets or sets the maximum number of concurrent entity work items that can be processed by the worker.
139+
/// </summary>
140+
public int MaximumConcurrentEntityWorkItems { get; set; } = 100 * Environment.ProcessorCount;
141+
}
126142
}

src/Worker/Grpc/GrpcDurableTaskWorker.Processor.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,10 @@ static string GetActionsListForLogging(IReadOnlyList<P.OrchestratorAction> actio
139139
return this.sidecar!.GetWorkItems(
140140
new P.GetWorkItemsRequest
141141
{
142-
MaxConcurrentActivityWorkItems = workerOptions.MaximumConcurrentActivityWorkItems,
143-
MaxConcurrentOrchestrationWorkItems = workerOptions.MaximumConcurrentOrchestrationWorkItems,
142+
MaxConcurrentActivityWorkItems =
143+
workerOptions.Concurrency.MaximumConcurrentActivityWorkItems,
144+
MaxConcurrentOrchestrationWorkItems =
145+
workerOptions.Concurrency.MaximumConcurrentOrchestrationWorkItems,
144146
},
145147
cancellationToken: cancellation);
146148
}

0 commit comments

Comments
 (0)