简体   繁体   English

在多种谷物之间分配繁重的工作(微软奥尔良)

[英]Distribute heavy work between multiple grains (Microsoft Orleans)

I want to compute an easy parallelizable calculation (eg Mandelbrot) with Orleans on different grains parallel and merge the result back together once the grains are done. 我想计算一个简单的可并行计算(例如Mandelbrot),其中Orleans在不同的晶粒上平行并且一旦晶粒完成就将结果合并在一起。 However, I am not sure how to do this or if Orleans is even the right framework for this kind of problem. 但是,我不知道如何做到这一点,或者奥尔良是否是解决此类问题的正确框架。 Also let me mention that this won't be any project which will go in production, I am just playing around with Orleans. 另外,我要提一下,这不会是任何将投入生产的项目,我只是在玩奥尔良。

Here is my idea so far: I have one graintype (let's call it "maingrain") which is an entry point for the client (might also be a grain). 到目前为止,这是我的想法:我有一个graintype(让我们称之为“maingrain”),这是客户端的入口点(也可能是一个粒子)。 This grain then estimates the amount of needed processing power and divides the task into smaller parts which are distributed to other grains from another graintype (I will call these "subgrains"). 然后,这种谷物估计所需处理能力的数量,并将任务分成较小的部分,这些部分从另一种谷物类型分配给其他谷物(我称之为“亚粒子”)。 It's no big deal to let these subgrains do the work and wait for a result which can be returned to the client, however I am not sure how to handle the subgrains. 让这些子晶片完成工作并等待可以返回给客户端的结果没什么大不了的,但是我不知道如何处理子晶粒。

Lets say, there is a call where I want to use 10 subgrains. 可以说,有一个电话我想要使用10个亚晶粒。 I get each by a new GUID and let them work. 我通过一个新的GUID得到每一个并让它们工作。 They are done and the client gets the result. 他们完成了,客户得到了结果。 Now there is a call where I want to use X subgrains: 现在有一个我想要使用X亚晶粒的电话:

  • Should I simply activate X new subgrains with X new GUIDs and let the garbage collector do the cleanup? 我应该简单地使用X个新GUID激活X个新的底色并让垃圾收集器进行清理吗?
  • Should I somehow reuse the previously activated subgrains (some kind of pooling) and how do I know that a subgrain is already reusable (=not busy)? 我应该以某种方式重复使用先前激活的亚晶粒(某种池),我怎么知道亚晶粒已经可以重复使用(=不繁忙)?
  • What happens, if I want to use multiple maingrains. 如果我想使用多个maingrains会发生什么。 Does each handle it's own subgrains? 每个都处理它自己的亚晶粒吗?

How would you do it? 你会怎么做? Thank you. 谢谢。

You can mark the subgrain as "StatelessWorker" using the Orleans.Concurrency.StatelessWorkerAttribute. 您可以使用Orleans.Concurrency.StatelessWorkerAttribute将子图标记为“StatelessWorker”。 This will then automatically scale out the grain (create multiple instances of the same grain) when there's a backlog of messages in it's queue, allowing for these sub tasks to be processed in parallel. 然后,当它的队列中存在积压的消息时,这将自动扩展粒度(创建相同粒度的多个实例),允许并行处理这些子任务。

Found this quite interesting regarding stateless workers: http://encloudify.blogspot.co.uk/2014/05/grains-grains-and-more-grains.html 发现这对于无国籍工人非常有趣: http//encloudify.blogspot.co.uk/2014/05/grains-grains-and-more-grains.html

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

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