Improve Performance Using Parallelism
  • Updated on 27 Dec 2018
  • 2 minutes to read
  • Contributors
  • Print
  • Comments
  • Share
  • Dark
    Light

Improve Performance Using Parallelism

  • Print
  • Comments
  • Share
  • Dark
    Light

#ServerlessTips - Azure Logic Apps
Author: Kent Weare Integration MVP

Azure Logic Apps naturally includes looping constructs that allow to iterate over a collection of records. For scenarios that require iterative processing, this is a really simple pattern. For example, if we need to copy records from an Excel spreadsheet to an Azure SQL Database, an Apply to each action will be placed on the Logic Apps design surface and will iterate through all of the Excel rows and perform database inserts for each record.

While Logic Apps makes it very simple to enable this Excel to Azure SQL scenario, it may take more time than you would typically anticipate if you have a single thread processing records. The reason is, for each insert into the Azure SQL database, a call is being made. The next record in the record set will not be inserted until the previous record has either succeeded or failed.

Let’s take a look at the following example, using the default configuration, it will take approximately 37 seconds to insert 256 records from an Excel spreadsheet to an Azure SQL database.

For each loops execute in parallel by default. Customize the degree of parallelism, or set it to 1 to execute in sequence.

Using the default behavior, we can see some parallel processing occurring. As a result, some reasonable performance.
1-standardconfiguration.png

If we require singleton-like processing, we can configure Degree of Parallelism to be set to 1. If we want more parallelism, beyond the default value of 20, we can increase this value up to 50.
2-parallelism.png

When we change this configuration, to have a single degree of parallelism, we will discover our throughput is significantly reduced. While the number in the image shows 1 minute, that number is rounded. The actual duration listed in our run history is 1:45.
3-results.png

Configuring parallelism is an important feature to understand. It has a direct impact on how a loop will be processed.

For processes that require first-in, first-out behavior, we want to set Degree of Parallelism to 1. For processes that do not require in-order delivery, we are free to modify our Degree of Parallelism. However, it is important to understand the connectors we are using may have rate limits imposed. This may mean that having a lower parallelism value will perform better than a larger value as we may avoid rate limits that will force retries from Logic Apps. For this reason, it is important to test with business scenarios to have the most predictable outcome.

Was this article helpful?