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
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.
Here is my host.json file
2
Answers
Logic App standard runs on Azure Function so you should be able to limit the numbers of concurrent calls using
host.json
settings:You could also set this setting using appsettings (see existing answer):
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.