integralzone

Mule 4 Scheduler in Multi-Worker Environment

Written by:
Published on April 23, 2021

Mule 4 Scheduler in Multi-Worker Environment

In MuleSoft projects, when there is a business requirement to self trigger a process, it can be realized in two unique ways: 

  1. Without human intervention Or
  2. Without external system invocation

This is based on two further basic approaches:

  1. Schedule based (cron
  2. Time interval based 

MuleSoft Scheduler

MuleSoft provides the following scheduling mechanisms:

  1. Fixed Frequency schedule: Can control the frequency with units of milliseconds, seconds, minutes, hours and days
  2. Cron Expression based schedule: Cron only supports from seconds upwards i.e. only frequency with units of seconds, minutes, hours and days.

If you ever wondered how the scheduler behaves in deployments to multiple workers on CloudHub, this article explains.

Scenario 1: One Worker and Single Scheduler


ModeBehaviour
Running in normal mode The scheduler runs as per schedule on that worker node.
Worker crashes The Application restarts and the Scheduler run as expected after a successful application start.

Scenario 2: More than One Worker and Single Scheduler


ModeBehaviour
Running in normal modeThe scheduler runs in only one worker node (primary node). The other nodes as a fail-safe.
Worker crashesIf the worker node in which the scheduler runs crashes, another available worker node runs the scheduler.

Scenario 3: One Worker and Multiple Schedulers


ModeBehaviour
Running in normal modeAll the Schedulers run as per their respective schedule on that single worker node.
Worker crashesThe Application restarts and the Scheduler run as expected after a successful application start.

Scenario 4: More than One Worker and Multiple Schedulers


ModeBehaviour
Running in normal modeAll the schedulers run in only one worker node (primary node)
The schedules run only on a single worker. There is no situation where schedules are divided across multiple workers.
Worker crashesIf the worker node in which the schedulers are running crashes, another available worker node takes the responsibility and executes all the schedulers as per their schedule. 

Can the Scheduler run when previously scheduled flow is still running?

No. If the previous trigger flow is still executing, the scheduler will not trigger another executing of the flow.

Example:

Consider a design scenario where a scheduler is used to load data from a database to a local object store (non-persistent object store). The behaviour in the multi-worker scenario is worth paying attention to from a design perspective. The data will only be loaded into one of the worker object store and not all other worker object stores.

When using an object store without persistence, the object store is local to the worker and not global across workers.

In this particular use case, the scheduler will only run on one worker, i.e. will only load the data to the local object store in one worker. Another worker local object store will not be loaded by the scheduler, as it will not run in other workers.

End note:

With this short article, we have tried to cover the way Mule 4 Scheduler works in Multi-Worker Environments and provided the outlook across varied and diverse scenarios.

If you found this article insightful, you may be interested in our article on why automated code quality should be the number one priority for Mulesoft applications?

To read the article follow the below link:


Leave a Reply

Your email address will not be published. Required fields are marked *

Other Blog Posts

Other Blog Posts

MuleSoft Runtime Code Scanning – Why Do You Need It?

One of the most frequently asked questions is if we have static code analysis and a well defined DevOps process, why would we need run time code analysis? In this article, let’s explore the differences between the two and why you might want to have runtime code analysis (and IZ Runtime Analyzer) even if you have …

Read more

Ensuring Software Quality in Healthcare: Leveraging IZ Analyzer for MuleSoft Code Scanning 🏥💻

Ensuring software quality in the healthcare industry is a top priority, with direct implications for patient safety, data security, and regulatory compliance. Healthcare software development requires adherence to specific rules and best practices to meet the unique challenges of the industry. In this blog post, we will explore essential software quality rules specific to healthcare …

Read more

Mule OWASAP API Security Top 10 – Broken Object Level Authorization

In Mule, Object-Level Authorization refers to the process of controlling access to specific objects or resources within an application based on the permissions of the authenticated user. It ensures that users can only perform operations on objects for which they have appropriate authorization. To demonstrate a broken Object-Level Authorization example in Mule, let’s consider a …

Read more

How KongZap Revolutionises Kong Gateway Deployment

In a rapidly evolving digital landscape, businesses face numerous challenges. Faster time to market is the only option business can choose. When it comes end to end Kong Gateway life cycle from deploying to managing Kong Gateway, every one of these challenges is applicable. However, KongZap, a groundbreaking solution is a game-changer by addressing some …

Read more