I have several workflows in my app that have conditional actions. All else being equal, is it better from a performance perspective to have multiple workflows, each of which will only be run under certain conditions, or to have one workflow with many conditionally run actions?
For simple workflows, I have not noticed a difference but am currently in the process of trying to speed up some of my slower workflows and would like to know if this would be a fruitful route to pursue.
I’ve found that it’s usually best done on the Event level (Button A is clicked and only when…) if the conditions don’t rely on the actions themselves like a User A/B Type action
If you do it on the action level and just having a singular Event, the workflow runs through every action every time even if most of them don’t meet the criteria. Instead if you have it on the Event level, you pre-determine which set of actions will be ran
Thanks @peng.o that makes a lot of sense, especially because some of my work flows require a search in the conditional, I realize now I was probably running that search multiple times which was a huge drag on performance, I’ll probably start moving all that out to the workflow level.
I agree with @peng.o.
Additionally, we’ve found there’s only 1 drawback with this approach - sometimes it takes a while for the first action to be triggered (because Bubble is checking which workflows to run first).
When that’s important to address, we’ve found a more advanced solution that solves for this without sacrificing performance. The approach is to have a single workflow run when the user clicks the button (no conditions on the workflow), then include a set of “Custom Events” that are conditionally triggered within that workflow. As such, you could also include actions that always run before or after these custom events (e.g., for example, update a custom state to make the button text a font-awesome loading icon).
Just FYI for anyone coming across this wants that immediate feedback to the user that the button has been clicked and the app is processing their request.
That’s a very intriguing idea. I’ll have to keep that in mind for the future. I have not played around much with the custom events yet except for the ‘on input value change’ so that is definitely an area of bubble I should start exploring.
Thanks for the help!