简体   繁体   English

我应该使用 Parallel.ForEach 来循环 DPS 链接的Hubs 吗?

[英]Should I use Parallel.ForEach to loop through the DPS linkedHubs?

Here is the scenario:这是场景:

  1. DPS with enrollmentgroup with more than one linked IotHub DPS 与具有多个链接的 IotHub 的注册组
  2. The enrollment group is associated with the custom function app.注册组与自定义函数应用相关联。

Custom function app:自定义功能应用:

  1. When the DPS request is made, a payload is sent to the DPS with the information that should determine what iothub(iothubhostname) the device should be registered to.发出 DPS 请求后,将向 DPS 发送负载,其中包含应确定设备应注册到哪个 iothub(iothubhostname) 的信息。

  2. The app will receive the payload along with list of linkedIotHubhostname in the requestbody该应用程序将在请求正文中接收有效负载以及linkedIotHubhostname 的列表

  3. App now needs to loop through the list of linkedIotHubHostname to determine which iothub the device belongs to based on the information provided.应用现在需要循环访问linkedIotHubHostname 的列表,根据提供的信息确定设备属于哪个iothub。

For step 3, should I be using Parallel_foreach given the case that more than one device might be provisioning at the same time?对于第 3 步,考虑到可能同时配置多个设备的情况,我是否应该使用 Parallel_foreach?

When multiple devices start provisioning at the same time, your Function will receive more requests.当多个设备同时开始配置时,您的功能将收到更多请求。 Depending on the function plan you chose , it will automatically create more instances to handle the load.根据您选择功能计划,它会自动创建更多实例来处理负载。 The execution time of your Function will have some impact on when scaling is necessary, but unless you're talking execution time of seconds, Parallel.ForEach is not likely going to make a difference.您的函数的执行时间将对何时需要缩放产生一些影响,但除非您说的是秒的执行时间,否则 Parallel.ForEach 不太可能产生影响。 It also depends on how many hubs and devices you're expecting to have.它还取决于您希望拥有多少集线器和设备。

You can deploy your function and check the execution time, optimise it later if necessary.您可以部署您的函数并检查执行时间,如有必要,稍后对其进行优化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM