Is there a way to make Workflows process

Is there a way to make Workflows process one at a time, instead of multiple running at once?
4 Replies
Olriko
Olriko2mo ago
Workflow instances are parallelized and step inside a workflow are executed one at a time
SODaLC
SODaLCOP2mo ago
Ah i see, thanks for the info. Was just curious because currently got a service i'm calling and the multi-workflows are causing too many requests at once causing each other to error. Was seeing if i could just stagger it.
avenceslau
avenceslau2mo ago
What I tend to do personally is have a Durable Object act like a lock. You do something like this: - DO has two methods request slot, release slot and an alarm (that ideally only runs if/when there are requests for slots so that you do the use the least amount of cpu time) - Your workflows in one of the steps request a slot and after that wait for event - Your DO sends events to the workflow instances that have request slots based on some amount of concurrency - After consuming the slot you call release slot on your DO In the future we might allow support something like what you are asking out of the box, but not currently in the mean time the approach above should work. If needed you could even make the Durable Object track the amount of requests per second so that you don't get rate limited.
SODaLC
SODaLCOP2mo ago
Oh now that's an interesting idea. Never considered that use case with DOs. Definitely something I'm going to explore. Thank you.

Did you find this page helpful?