skip to Main Content

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

2

Answers


  1. 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
    
    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search