0

I have a scenario where I receive messages from service bus to trigger a workflow. This workflow does some processing but ultimately inserts some data into SQL DB. When 100,000's of messages appear at once, the DB gets overwhelmed.

Is there a way of restricting the number of concurrent instances?

Here is my test

workflow

This receives a non session message, has a 2 minute delay, then a compose just to ad an end activity.

If I submit 10 messages, enable the workflow, immediately all 10 messages cause 10 workflows to activate.

enter image description here

Here is my host.json file

enter image description here

Jason Hyland
  • 744
  • 1
  • 8
  • 21

2 Answers2

0

Logic App standard runs on Azure Function so you should be able to limit the numbers of concurrent calls using host.json settings:

{
    "version": "2.0",
    "extensions": {
        "serviceBus": {
            "clientRetryOptions":{
                "mode": "exponential",
                "tryTimeout": "00:01:00",
                "delay": "00:00:00.80",
                "maxDelay": "00:01:00",
                "maxRetries": 3
            },
            "prefetchCount": 0,
            "transportType": "amqpWebSockets",
            "webProxy": "https://proxyserver:8080",
            "autoCompleteMessages": true,
            "maxAutoLockRenewalDuration": "00:05:00",
            "maxConcurrentCalls": 16,
            "maxConcurrentSessions": 8,
            "maxMessageBatchSize": 1000,
            "sessionIdleTimeout": "00:01:00",
            "enableCrossEntityTransactions": false
        }
    }
}

You could also set this setting using appsettings (see existing answer):

AzureFunctionsJobHost__extensions__serviceBus__maxConcurrentCalls
Thomas
  • 24,234
  • 6
  • 81
  • 125
  • Hi thanks for your answer, unfortunately this configuration as no effect on either the number of messages grabbed at once by the logic app trigger, or the number of concurrent flows. – Jason Hyland Jul 08 '22 at 10:54
0

You can apply concurrency control at the app level (similar concept to what Thomas suggested, but there are specific toggles for Logic Apps). The link below points to those values:

https://learn.microsoft.com/en-us/azure/logic-apps/edit-app-settings-host-settings?tabs=visual-studio-code#trigger-concurrency

The value you are looking is Runtime.Trigger.MaximumRunConcurrency (and this is applied in the hosts.json). There is some guidance in the document on how to setup host.json (scroll up a bit).

Another option is to remove the split on, so you receive an array with all the messages and use a for-each loop, where you have more control on loop concurrency.

I hope this helps.

Cheers, Wagner.

Wagner Silveira
  • 1,576
  • 11
  • 9
  • This setting only works for recurrence based trigger - see the following - https://learn.microsoft.com/en-us/azure/logic-apps/edit-app-settings-host-settings?tabs=azure-portal#trigger-concurrency – abhijat_saxena Aug 29 '23 at 22:06