Scale Workloads Using SplitOn feature - Azure Logic Apps
When a batch of records gets sent to Azure Logic Apps, the processing of that batch will be processed sequentially, unless we decide to parallelize the processing of those records.
There are a couple ways we can do this, including using the Degrees of Parallelism feature or we can use the splitOn feature in our trigger.
The splitOn feature can be added in the ‘code-behind’ of a logic app. The syntax for doing so looks like the following: "splitOn": "<splitOn-expression>". When the trigger receives a message that contains a batch of records, it will split on the expression that is provided. Each node within the batch message will get sent to a new instance of the logic app. This will allow us to parallelize our processing by having many concurrent logic apps active.
Let’s take a look at a simple scenario where we will retrieve work orders from a SQL database, based upon a schedule. We will call this our publishing logic app. Within our publisher, we will send our result set to a second logic app, known as our consumer, through the HTTP action.
In our consumer logic app, we will have an HTTP trigger. To illustrate how our message will be processed after it has been split we will just use an HTTP action.
With our consumer logic app in the designer, we need to go to code view so we can modify our trigger and implement our splitOn expression:
Let’s now run our publisher logic app and observe the behavior. Our publisher logic app retrieved 5 records from our Azure SQL database. But, it only called our consumer logic app once. Since we are using the splitOn feature, the Logic Apps engine was able to instantiate one logic app for each record.
If we look at our run history, we will discover only a single record was sent into each instance of our logic app which demonstrates our splitOn expression worked properly.
As we have observed, Logic Apps is very flexible when it comes to sequential and concurrent processing patterns.
Whether we decide to use Degrees of Parallelism in Apply to each loops or the splitOn feature, we have many options to handle flow control.