In this tutorial, you will learn what cycles are and the relationship between cycles and the maximum number of results returned in a single execution.
The tutorial on What Are The Benefits of Increasing The Number of Cycles? is a continuation of this one. In it, we will explain the benefits of increasing the number of cycles and how that affects data processing during a scenario execution.
So what are these cycles?
As you already know, a scenario executes as per its schedule, which by default is set to every 15 minutes. And the number of cycles is set to 1 by default.
When a scenario is executed manually by clicking Run once, what you see is 1 cycle of the scenario execution. When the Maximum number of cycles is increased, the whole scenario, that is, all the modules in the scenario, will be processed multiple times during a single execution.
In other words, this entire process of the trigger module fetching data and the action module processing the data is repeated multiple times. And the maximum number of repetitions is equal to the Max number of cycles specified.
Now, a scenario typically begins with a trigger module. However, even if it begins with an action module, it accounts for the Max number of cycles specified.
For the sake of simplicity and to demonstrate the benefits of Cycles, it is assumed that a scenario always begins with a trigger module.
The scenario consists of the following modules:
- Gmail > Watch emails
- Gmail > Mark an email as read
As you can see, the Gmail > Watch emails trigger module has been added here. It has been set up to fetch Only Unread emails from the Inbox and the Maximum number of results is set to 5. This tells Integromat that a maximum of 5 emails are to be fetched in one cycle of a scenario execution:
Let’s say there is only 1 unread email in my inbox (wishful thinking, I know), Integromat can only fetch, well, 1 email as per the specified criteria.
Okay. Now let’s select All emails here to process all unread emails:
And run the scenario once by clicking Run once:
You can also choose to Run this module only; the result will be the same:
Scenario execution 1
Looking at the output, you can see that the module outputted 5 bundles of data, each corresponding to one email:
Also, only 1 operation was consumed as all 5 emails were fetched in one go:
As mentioned earlier, manual executions of a scenario only take place in 1 cycle. But even if we activate the scenario which is scheduled to execute every 15 minutes, it will only fetch 5 emails during one execution since the Max number of cycles is unchanged.
Before we increase the number of cycles, let’s go ahead and add another module here. Let’s select the Gmail > Mark an email as read module.
Select Inbox under folder and under Email ID, map the Email ID item outputted by the previous module:
Let’s run it again..
Scenario execution 2
OK so the trigger module fetched 5 emails in one go as it did earlier, and the action module processed each of them one by one, consuming 5 operations. This execution consumed a total of 6 operations:
Now it’s time to show you how increasing the number of cycles affects the scenario execution..
First, let’s go ahead and change the Maximum number of results here to 1:
And change the Max number of cycles to 5. The cycles setting is found under the scenario settings here:
If we run the scenario once, it will only fetch 1 email and mark it as read. So let’s go ahead and change the schedule to run the scenario every 1 minute, save the scenario and activate it:
Now wait for 1 minute and then check the scenario History:
Scenario execution 3
Each entry here refers to one scenario execution and you can see that the last execution consumed 10 operations:
Let’s look at the details of this execution by clicking here:
On the top-right-hand side, you can see that the execution contains 5 cycles, and each cycle can be examined separately:
Looking at the output of the trigger module, you can see that as per the maximum number of results specified, only 1 email was outputted by the trigger module and was marked as read by the action module. Both modules consumed 1 operation each:
Similarly, each of the subsequent cycles fetched and processed 1 email, bringing the total consumption of this execution to 10 operations.
Remember, the previous set up had also processed 5 emails but consumed only 6 operations since the Maximum number of results was set to 5 and the scenario was executed in 1 cycle:
At this point, you might say to yourself “Why would I ever increase the number of cycles, especially when it consumes more operations?”
The tutorial on What Are The Benefits of Increasing The Number of Cycles? answers exactly that.
Before you proceed, take note of the things to keep in mind when working with cycles.
- The Maximum number of cycles specified determines the maximum number of times Integromat processes the whole scenario during one scenario execution
- The Maximum number of results specified in a trigger module is equal to the number of bundles of data outputted by the module during one cycle of the scenario execution.
- Only scheduled scenario executions take into account the number of cycles specified. Manual executions only take place in 1 cycle, ignoring the cycles specification altogether.
- The cycles specification is taken into account even if a scenario begins with an action module.
- Lastly, a scenario that begins with an instant trigger or a webhook ignores the cycles specification altogether. This is because an instant trigger, by its very nature, is triggered by an external event, and therefore, it always outputs one bundle of data.
That covers the fundamentals of Cycles.