Skip to content

Logic App Standard - Slow Performance - Loops #503

Description

@JamieH-risual

Creating a simple workflow which has actions to create an array of x items, loop through the items and add the current time into another array variable the performance seems extremely slow/limited. I’ve amended multiple host settings which are mentioned to increase throughput (Such as Jobs.BackgroundJobs.NumWorkersPerProcessorCount) and also concurrency settings with no significant impact. When setting the for each loop concurrency to its max(50 concurrent iterations) it completes the workflow in the following approximate times:

500 items: 30 seconds
1000 items: 2+ minutes
5000 items: 30 minutes

I’d expect all of these to be less than a minute with some of the lower end being within milliseconds. There does not appear to be an issue with the underlying compute as the % CPU and Memory do not exceed 70% and the plan never scales even under load which feels like there is either limitations of the product, configuration restricting throughput or a potential bottleneck somewhere such as the associated storage account.

I know that there is a SplitOn() feature which can be used to separate workflows for processing but I have a requirement to extract 100,000's of messages from a Service Bus and transform them into a single batch. I'm hoping to understand if there is an issue with configuration which can be updated to massively improve the throughput or whether the limitation is due to the product and if we need to switch to using Azure Functions.

An example workflow which can be used for testing is below:

{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "Compose": {
                "inputs": "@variables('testArray')",
                "runAfter": {
                    "For_each": [
                        "Succeeded"
                    ]
                },
                "type": "Compose"
            },
            "Execute_JavaScript_Code": {
                "inputs": {
                    "code": "return Array.from({length: 5000}, (x, i) => i);"
                },
                "runAfter": {
                    "Initialize_variable": [
                        "Succeeded"
                    ]
                },
                "type": "JavaScriptCode"
            },
            "For_each": {
                "actions": {
                    "Append_to_array_variable": {
                        "inputs": {
                            "name": "testArray",
                            "value": "@{items('For_each')}: @{utcNow()}"
                        },
                        "runAfter": {},
                        "type": "AppendToArrayVariable"
                    }
                },
                "foreach": "@outputs('Execute_JavaScript_Code')",
                "runAfter": {
                    "Execute_JavaScript_Code": [
                        "Succeeded"
                    ]
                },
                "type": "Foreach"
            },
            "Initialize_variable": {
                "inputs": {
                    "variables": [
                        {
                            "name": "testArray",
                            "type": "array"
                        }
                    ]
                },
                "runAfter": {},
                "type": "InitializeVariable"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "triggers": {
            "Recurrence": {
                "recurrence": {
                    "frequency": "Day",
                    "interval": 15
                },
                "type": "Recurrence"
            }
        }
    },
    "kind": "Stateful"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions