AnsweredAssumed Answered

How can I ensure scheduled tasks aren't duplicated in a highly available setup

Question asked by Thomas O'Brien on Feb 26, 2019
Latest reply on Feb 26, 2019 by Thomas O'Brien

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
  • 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!