Seperate Workflows vs. Monolithic Workflow

In general are there any best practices for when to run everything in a single monolithic workflow vs. multiple concurrent workflows?

I have a workflow that runs when a form is submitted that makes several separate calls to chatGPT api using the GPT plugin. There is no explicit need for these calls to be sequential. But as is the workflow has to wait before starting the next one. As far as I can tell, there is no way to have things in a ingle workflow run concurrently.

Would it make sense to break these out into separate workflows to hopefully run them more concurrently and hopefully speed things up? Or is that sort of “hack” typically frowned upon for performance reasons?

Have you played around with the ‘multi-option split’? Might allow you to run concurrent paths. I haven’t tried it myself.

Unfortunately, as far as I can tell, it just defaults to option 1 instead of running all arms.

You can use js to trigger multiple global workflows concurrently.
In a javascript action you can execute a global workflow like this: wwLib.executeWorkflow('workflowID',{yourParameter: 'yourValue'})
You can find the workflow id by enabling “show dev informations” in the “dev” menu.

executeWorkflow is an async function, so if you call it without awaiting it you can run multiple workflows concurrently.
Of course to properly manage error handling with the “onError” workflow you need to await somewhere the promises returned by executeWorkflow.

At the moment, workflows are sequential for UX-purposes (easier to understand and debug for users). I’ll add an action to the roadmap to execute actions in parallel :wink:

1 Like

Is that necessary though? I am aiming to have the workflows run when I press a button.

Can’t you just set up two separate workflows that both get triggered when the button is pressed? Or will those still not run in unison?

Screenshot 2023-06-06 at 7.54.34 AM

And if they will indeed run together, is that an acceptable practice in terms of performance?

It’s not necessary and it’s not the only way to achieve parallel workflow execution.
You asked if there was a way to run actions concurrently and I suggested one.
It’s entirely up to you and your specific circumstancesdeciding what’s better for performance.

As Quentin said sequential actions are easier to debug. If you think the performance it’s too slow you can test a concurrent approach and see if it’s faster.

Yes they will run in parallel, and yes its acceptable, unless they are very very heavy (huge loop with thousands of items)

Would be nice to have it in a format of a “for loop” but with parallel execution.