-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Eager Workflow Task Dispatch on SDKs #242
Labels
enhancement
New feature or request
Comments
This was referenced Mar 7, 2023
This was referenced Sep 25, 2023
This was referenced Jan 29, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Objective
To reduce the latency between
WorkflowClient#start
call and the dispatching of the workflow task to the worker, a new Server feature that performs an "Eager Workflow Task Dispatch" on a start call was implemented.See relevant Server PRs for details:
temporalio/temporal#3835
temporalio/temporal#3928
TL;DR
A
WorkflowClient
that is aware of an existing local workflow worker can request an eager Workflow Task on thestart
call and get the first Workflow Task of the Workflow Execution back immediately in the Start call response. This allows Server toWorkflowExecutionStarted+WorkflowTaskScheduled
events andWorkflowTaskStarted
event.Start Call
WorkflowClient awareness of WorkerFactory
WorkerFactory
shouldregister
itself on theWorkflowClient
the last thing during start andderegister
itself as the first step during a shutdown.WorkflowClient
implementation should maintain a set of registeredWorkflowFactory
.WorkflowClient
MUST tryWorkflowFactory
from the registered ones in random order.WorkflowFactory
, as its corresponding worker can be paused or get into a shutdown state right after selection. If this happens,Worker#reserveWorkflowExecution
will return a null or another token meaning unsuccessful reservation and the next randomWorkflowFactory
SHOULD be used in an attempt to get the reservation.WorkflowClient
should have oneWorkflowFactory
at a time. So the performance of this random selection is not that important. Legitimate situations whenWorkflowClient
has several registeredWorkerFactory
:WorkerFactory
as means of “horizontal” scaling. It doesn’t make much sense to do. Instead, users should be scaling workers up. But it’s totally allowed by the current API at the moment. And it’s not an illegitimate approach. We don’t want all eager tasks from a WorkflowClient to be dispatched to only one WorkerFactory out of all assigned to the WorkflowClient.Eager Dispatch Flow implementation notes
WorkflowOptions
gets adisableEagerExecution
flag that is “false” by default.The same instance of
WorkflowClient
that was used to createWorkerFactory
SHOULD be used forWorkflowClient#start
call to be performed with a local eager dispatch. ThisWorkflowClient
MAY also be obtained fromWorkflowFactory
A corresponded worker MAY decline eager dispatch for any reason by
WFTDispatchHandle
onWorker#reserveWorkflowExecutor
call. WorkflowClient shouldn’t request eager dispatch from the Server then.false
toWFTDispatchHandle#dispatch
call on an already obtained reservation.It SHOULD decline if
ACTIVE
(ConsideringNOT_STARTED
,ACTIVE
,PAUSED
,SHUTDOWN
,TERMINATED
)Local Workflow Completion
The original proposal included the concept of Local Workflow Completion. The idea was that a worker after receiving an eagerly dispatched workflow task may return a workflow completion promise that will be completed once the workflow is completed locally.
Later it was taken out because it was understood that this concept will provide little to no benefits. Reasoning: to provide local completion consistently with persisted history, the local completion should be filled by the worker only after receiving a response from the Server on the workflow task completion request. There is currently no reason to assume that this response will be received much earlier than a completion of a long poll opened by the Workflow Client for a workflow completion event. Both should typically be arriving on a single server → client trip.
SDKs supports
The text was updated successfully, but these errors were encountered: