逻辑应用程序-foreach循环非常慢 [英] Logic Apps - foreach loop very slow

查看:67
本文介绍了逻辑应用程序-foreach循环非常慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到,Azure Logic Apps中的循环(使用foreach)非常慢.举例来说,我遍历了一个包含8.000个JSON节点(共1.6MB数据)的http结果,处理过程大约花了6分钟,与在.Net应用程序中进行处理相比,这是一个非常长的时间.这是测试的完成方式:测试逻辑应用,在此测试中,JSON数据来自Blob

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

对我来说,遍历结果集是一项常见的任务,它应该这么慢吗?你们中有人知道更好的方法来解析和循环Logic Apps中的数据吗?

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?

推荐答案

之所以较慢,是因为循环的并发默认值为20,最大值为50.解决此问题的最佳方法是使用略有不同的模式,您正在分派到另一个逻辑应用程序的地方.例如,您将拥有一个逻辑应用程序,该逻辑应用程序生成您要循环遍历的数组,然后创建另一个逻辑应用程序,该应用程序接受http请求作为触发器.在第二个逻辑应用程序的设置下,启用spliton功能.现在,将您的工作"放入第二个逻辑应用程序中,然后返回第一个并进行最后一步,将阵列发送到第二个逻辑应用程序.使用此模式时,第一个逻辑应用程序将为数组中的每个项目初始化运行,它们将全部同时运行,而不仅限于for每个循环的并发性.这是有关此功能的文档中的更多详细信息. https://docs.microsoft.com/zh-CN/azure/logic-apps/logic-apps-workflow-actions-triggers#split-on-debatch

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

这篇关于逻辑应用程序-foreach循环非常慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆