Do repeating rules run in parallel or serial?

I have many per-user rules that trigger every five minutes. I was concerned that having so many rules running at the same time would be taxing and wondered why there isn't a way to stagger these rules (eg: user1 's rules starts at when minute is xx:00, user2's rules start when minute is at xx:02, etc). But if rules only run in serial, then I don't need to worry? Or don't micromanage the magic?

You could use a periodic schedule and define a cron string to triggers every 5 minutest that start at different time. For example
Rule 1 - 1,6,11,16 0 ? * * *
Rule 2 - 2,7,12,17 0 ? * * *

I'm thinking if there isn't an obvious issue with performance now, I'd leave it be. But you could also daisy-chain the rules so when the first one ends it kicks off the second.

You can use a custom cron string as a schedule and stagger the start times yourself if you want; this looks like the option proposed above. To directly answer the other part, if two jobs--from any source, app (including rule) or driver--are scheduled at the same time, they will start executing at more or less the same time, though likely with milliseconds of each other in an unspecified order--so basically in parallel in that one will not wait for the other to "complete" first.

Alternatively, I might look at why you are using periodic triggers in the first place. Being an event-driven system, Hubitat often works better if you respond to events, most commonly device events, rather than just doing things on a loop. Timed things certainly have their place, but it sounds like you might be concerned, so maybe sharing more about what you're doing and why would help someone give more targeted advice.

1 Like

These are all rather good options to consider. Trying the CRON method now. Not sure how to check the load on the system over time, but probably overthinking it for the sake of efficiency.

As for why I have a time-based rule...
I have a rule that monitors the battery level of each user's phone and toggle smart outlets to keep the charge between 70 and 80. I originally had a trigger for whenever the battery level changes, but I needed an alternative so the rule can run again so it can perform other actions if the result of the previous actions are not as expected (eg: toggle the switch again, send a message to the user to manually unplug/plug phone, etc). And to account for when the phone charges up to 100%, after which there will not be any more battery level changes as long as it's still plugged in.

Download the Hubitat app