Logic Apps - foreach loop very slow

浪子不回头ぞ 提交于 2021-02-09 18:57:39

问题


I've noticed that looping (using foreach) in Azure Logic Apps is very slow. As an example I've looped over a http result containing 8.000 JSON nodes (altogether 1.6MB data) and it took around 6 minutes to process which is an extremely long time compared with doing it in a .Net application. This is how the test was done: Test logic app, in this test the JSON data comes from a blob

For me it's a common task to loop through a result set, should it be this slow? Do any of you know a better way to parse and loop data in Logic Apps?


回答1:


The reason it is slow is because the concurrency for loops is default of 20 and max of 50. The best way around this is to use a slightly different pattern, where you are debatching to another logic app. For example you'll have your one logic app that generates the array that you want to loop through, then create another logic app that accepts an http request as a trigger. On the second logic app under settings enable the spliton function. Now put your 'work' in the second logic app, then go back to the first and make the last step to send the array to the second logic app. When using this pattern the first logic app will initialize a run for each item in the array, they will all run concurrently, rather than limited to the concurrency of the for each loop. Here is some more detail in the documentation about this function. https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-workflow-actions-triggers#split-on-debatch



来源:https://stackoverflow.com/questions/49319978/logic-apps-foreach-loop-very-slow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!