I'm in the process of creating a highly available Sugar setup
Web servers are basically only running Sugar, everything else is separated out (database, session handling, upload storage and elasticsearch).
The thing I'm struggling most with is cron/scheduled tasks.
I'm guessing that cron should only run on one instance, to prevent duplication of scheduled tasks (I'm guessing this is necessary, please correct me if I'm wrong, I struggle to find documentation on this), however I'm struggling to find a way to do so in an automated manner.
Our deployment is automated and we're treating our instances as disposable, so I'm looking for a way to either:
- Run cron on only one instance
- I can probably do this through checking for a "cron" tag on the instances in the autoscale group -> if the tag doesn't exist, then enable cron on instance and apply the "cron" tag
- This seems like a messy solution and I'm reluctant to use it unless there's no other way
- I can probably do this through checking for a "cron" tag on the instances in the autoscale group -> if the tag doesn't exist, then enable cron on instance and apply the "cron" tag
- Run cron on all instances, but lock tasks to one instance
- I previously tried cronlock for this, but it caused really weird behaviour/lockups in Sugar.
Ideally I'd like to avoid having a separate cron server
Would really appreciate some input/guidance!