AEM Cloud: is scheduler run on each instance? | Community
Skip to main content
May 6, 2021
Solved

AEM Cloud: is scheduler run on each instance?

  • May 6, 2021
  • 2 replies
  • 5362 views

I have found relatively little info about schedulers in AEM, but I understand you can schedule them like cron jobs, e.g. run every 5 mins.

 

With AEM cloud, Adobe take care of spinning up additional instances as required by load.  

In this case, will multiple copies of each scheduler be run?  Or does AEMN have some kind of master and slave schedule service, so each scheduler only runs once?

 

The same question applies to ehcache - does each publish instance get its own copy of the cache?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by joerghoh

By default the scheduler runs on all instances, and that's not different at all to any on-prem and AMS based environment. For clustered instances (like the authoring instances in AEM as a Cloud Service) you have the option to run it only on the master.

 

The documentation available at https://sling.apache.org/documentation/bundles/scheduler-service-commons-scheduler.html is quite good and explains also howto run a scheduled job only once per cluster.

2 replies

Kiran_Vedantam
Community Advisor
Community Advisor
May 6, 2021

Hi @tb3dock,

 

Schedulers are event handling mechanism which can run on the instance as per the cron job provided. They would run on the instance if the code is present in them - even though adobe creates some extra instances [which would be a backup or replica of existing instances]

 

To know more on the annotations of different event handling mechanisms please check my blog here.

 

Hope this helps!

 

Thanks,

Kiran Vedantam

TB3dockAuthor
May 6, 2021
thanks for the reply. This doesnt answer the question unfortunately. If I have a scheduler in my myode, and I only deploy to a local author instance, I will only get one copy of the scheduler running. However, If I deploy my code to aem cloud production env, will mulitple copies of my scheduler run, or does it guarantee only a single copy be run? This is critical.
joerghoh
Adobe Employee
joerghohAdobe EmployeeAccepted solution
Adobe Employee
May 6, 2021

By default the scheduler runs on all instances, and that's not different at all to any on-prem and AMS based environment. For clustered instances (like the authoring instances in AEM as a Cloud Service) you have the option to run it only on the master.

 

The documentation available at https://sling.apache.org/documentation/bundles/scheduler-service-commons-scheduler.html is quite good and explains also howto run a scheduled job only once per cluster.

February 7, 2023

@joerghoh in your reply you state that this works for AEM authoring instances on AEMaaCS. However, does this work if we want to run a job on the AEM publish tier leader (ie. run on exactly one publisher regardless of AEM's auto-scaling)? It's a bit difficult to test this early to confirm as we'd need to release to staging (since AFAIK there's no way to simulate auto scaling on dev envs). Thank you!

joerghoh
Adobe Employee
Adobe Employee
February 9, 2023

Hi,

 

currently it is not possible to run a job exactly once on the publish tier. In my opinion this hardly makes sense especially because you typically want to execute this operation when ALL publishs have received some content, and currently this is not possible to know on the publishs themselves.