Sleep vs start delay

For delaying execution of workflows, it was mentioned sleep is the way to go from this link. A year after that, start delay was introduced. Which is the better option now, and why? I am having the same use case from the linked post.

Hi @sshanzel

Both create a timer on the server. With start-delay, you won’t see the timer in your workflow execution (workflow history) , and the first workflow task will be scheduled after the start-delay value you have set.

Unless you need to update the timer (see this example samples-typescript/timer-examples/src/updatable-timer.ts at main · temporalio/samples-typescript · GitHub ) I think you can use start-delay from now.

Antonio

1 Like

Awesome. Thank you for letting me know.

I think there can be pros and cons with using either of them. For sleep, if you do a few activities first before going to sleep, when the timer is up, you are much closer to the execution of what you would want to do at the end as opposed to scheduling a delay, then certain activities might take time which final execution would have to consider those intervals. Anyway, it would probably be just a matter of few seconds.

With that, I will proceed with start-delay. Just sharing my thoughts. Thanks!

1 Like