You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to implement workflow core in an existing system and one of the requirements is to be possible for x number workflows to run concurrently.
At first glance I though that the option UseMaxConcurrentWorkflows could achieve this, but after some testing I realized that this options controls how many steps run concurrently and not how many workflows.
This is the code I am using for testing this behavior:
// Workflow registration - I am using prostgres for persistance and redis for queue// also for this example I set UseMaxConcurrentWorkflows to 2builder.Services.AddWorkflow(options =>{options.EnableLifeCycleEventsPublisher=true;options.EnableWorkflows=true;options.EnablePolling=true;options.EnableIndexes=true;options.EnableEvents=true;options.UseMaxConcurrentWorkflows(2);options.UsePostgreSQL(databaseConnectionString,true,true);options.UseRedisLocking(queueConnectionString);options.UseRedisQueues(queueConnectionString,"api-queue");options.UseRedisEventHub(queueConnectionString,"api-channel");});
// The example workflow I am testing with with only 3 stepspublicclassWorkflowA:IWorkflow<ContextA>{publicstringId=>"WorkflowA";publicintVersion=>1;publicvoidBuild(IWorkflowBuilder<ContextA>builder){builder.StartWith<StepA1>().Then<StepA2>().Then<StepA3>();}}
// each step does the same thing - they delay the execution for some time (3 seconds) and then move onpublicabstractclassBaseStep:IStepBody{publicasyncTask<ExecutionResult>RunAsync(IStepExecutionContextcontext){varworkflowContext=(ContextA)context.Workflow.Data;awaitTask.Delay(TimeSpan.FromSeconds(workflowContext.StepExpectedDurationInSeconds));returnExecutionResult.Next();}}
Let's say that over the course of 5 seconds every second I send a request to my app that starts a new WorkflowA.
I expect that the first two requests will add two workflows to the queue and these will run concurrently to the end and then start the next two workflows in the queue.
Instead, the queue does not have workflow but steps, and it only runs the first step in two workflows and then sends step 2 to the end of the queue. In my real use case this means that step 2 will sometimes run hours after step 1 was finished (since we are always receiving new requests to start new workflows) and this is a problem.
Is this the default behavior or am I misconfiguring something? And if it is default behavior, are there options available to customize this?
The text was updated successfully, but these errors were encountered:
felix2000jp
changed the title
[Question] What exactly does the option UseMaxConcurrentWorkflows affect?
[Question] What does the option UseMaxConcurrentWorkflows do?
Jun 13, 2024
Hi!
I am trying to implement workflow core in an existing system and one of the requirements is to be possible for x number workflows to run concurrently.
At first glance I though that the option
UseMaxConcurrentWorkflows
could achieve this, but after some testing I realized that this options controls how many steps run concurrently and not how many workflows.This is the code I am using for testing this behavior:
Let's say that over the course of 5 seconds every second I send a request to my app that starts a new
WorkflowA
.I expect that the first two requests will add two workflows to the queue and these will run concurrently to the end and then start the next two workflows in the queue.
Instead, the queue does not have workflow but steps, and it only runs the first step in two workflows and then sends step 2 to the end of the queue. In my real use case this means that step 2 will sometimes run hours after step 1 was finished (since we are always receiving new requests to start new workflows) and this is a problem.
Is this the default behavior or am I misconfiguring something? And if it is default behavior, are there options available to customize this?
The text was updated successfully, but these errors were encountered: