Workflow execution model

I was wondering if someone might be able to describe the execution model for workflows?

Are workflows blocked during execution or will another thread execute the same workflow code if a new trigger is received from a second device while the previous run from a first device was still executing?

I’m considering introducing a delay node but I’m thinking through the consequences of dong so when my workflow triggers are asynchronously arriving at unknown times and frequency from many devices.

Thanks

Paul

Hi @paul_wareham,

We do have a Losant University chapter on this, it can be found on this page, and is Course 5, Chapter 4: Workflow Mechanics. Workflows are never blocked for another flow, so each trigger will kick off its own flow. If you did need to use data from a previous run, however, you can share state using workflow storage.

Thanks!
Julia

@JuliaKempf

Thank you. The university chapter was great (the hyperlink in your post goes to the wrong page by the way).

The chapter doesn’t specifically address multiple executions of the same workflow. However, my understanding from your comment is that the same workflow can be triggered multiple times and each of the flows will essentially be executed in parallel. For example, let’s say we have a workflow to parse data from devices triggered by a Webhook which will ultimately update state. The webhook can be triggered by multiple devices at any time. Device 1 might trigger the workflow and before its finished executing, Device 2 might trigger the same workflow. However the first execution for Device 1 will not block the execution relating to Device 2.

Just double-checking that my understanding is correct.

Thank you!

Paul

@paul_wareham,

Yes you are correct. Workflow runs do not affect other runs (unless you’re doing so explicitly with Workflow Storage). You can think of each Workflow as its own stateless function. It is correct to assume that Workflows be executed in parallel, but all in all, no order is guaranteed.

1 Like

very clear. Thank you so much guys!