I’m creating a Step function workflow with multiple embedded workflows (using startExecution.sync:2). I noticed that all of the embedded workflows appear to have a 2-3 second overhead. This appears to be the same across all of my embedded workflows. Is this normal or am I doing something wrong?
Looking at the runtime for the logic in one of the embedded workflows, the time spent was milliseconds, however, when looking at the parent the time spent on that execution task was over 2 seconds. I would have expected it to only tike milliseconds at the parent level as well.
2
Answers
Update: I contacted AWS support and they responded with the following:
Switching to the waitForTaskToken worked for me.
2-3 second latency between completion of a job executed using the Run a Job (.sync) integration pattern and continuation of the Step Functions Workflow is not uncommon.
With these optimized integrations, Step Functions makes a call to the target service (in this case to itself) to start an asynchronous process (in this case a Step Functions Workflow Execution). The target service returns an identifier for the asynchronous process to Step Functions which pauses calling workflow execution.
Step Functions then polls the target service (typically using a
Describe*
API Action) at a regular interval to determine when the job completes. For serivces which support Amazon EventBridge events, Step Functions will create a Managed Rule in your account so that it can learn of job completion more quickly (Step Functions is one such service). When the calling workflow execution learns of completion via an event or a poll response, it continues the workflow execution.Given these asynchronous interactions, there will be latency between completion of the job and resumption of the calling workflow execution.
If Express Workflows will meet the needs for your embedded workflows, you can call them using the StartSyncExecution API Action with AWS SDK Service Integrations. Step Functions will then call these synchronously in the same way it does with AWS Lambda which will reduce the latency.