How to perform distributed computations with F# (.Net)

时间:2016-01-17 18:55:20

标签: .net f#

So I just had a little fun in F# with the Async library recently and was very amazed by especially Async.Parallel which basically takes a sequence of Async tasks and unifies them under one Async task.

However, now I am curious on how to distribute a computation task between multiple computers, say for example the two laptops on my desk.

Is it somehow possible to serialize these Async tasks and send them to another computer which then performs the task and sends the result back?

Or maybe I need to serialize the data itself and send it to the other computer, on which I have some code running that performs the computation and sends result back?

Or maybe there is another simplistic way to do it?

What is the general approach to distributed computing in F# using .Net? (recommended design patterns, tools, libraries, etc.)

My end goal is to split a big computation task into smaller parts and run them on multiple machines. Preferably in a simplistic non-enterprise-overly-complex-way.

3 个答案:

答案 0 :(得分:13)

有一个名为MBrace的项目,它完全按照你的描述完成: - )。

它允许您使用cloud块编写云计算:

let first = cloud { return 15 }
let second = cloud { return 27 }

您可以使用let!和异步工作流一起构建它们,也可以使用Cloud.ofAsync从异步工作流创建它们。可以使用Cloud.Parallel

在网络上分布云计算
cloud {
  let! results = [ first; second ] |> Cloud.Parallel
  return List.sum results }

目前,有一些MBrace绑定用于在本地运行计算(用于测试)和Azure集群内部,但是在支持Amazon方面也有一些正在进行的工作。

有关更多信息,请参阅mbrace.io,Mathias Brandewinder在crunching through big data with MBrace上也有一个很好的演讲

答案 1 :(得分:2)

fsharp.org有一个处理https://github.com/mikeobrien/HidLibrary的页面,它提供了有关此事的最新资源。

正如Tomas Petricek所说,Cloud Data, Compute and Messaging with F#似乎是在F#中进行分布式计算的惯用方法。遗憾的是,它专注于云计算(Azure和亚马逊),并提供有关本地多机群集的极少信息。我找到了MBrace来处理这个主题并且似乎提供了一个解决方案但是官方教程(可能还有一些内置函数)会很好。

Microsoft的thread是在F#中开发的,它提供了Sparks的替代方案。该文档解释了如何构建本地Prajna(仅在Windows机器上)。这可能是最简单的解决方案,但似乎已经死了。

另一种选择可能是akka.net,其中有multi-machine clusters

答案 2 :(得分:2)

我绝对推荐你akka.net。我目前正在使用它实现分布式集成解决方案,并且可以告诉你这很棒。微软研究院的奥尔良项目也很不错,虽然它不是惯用的f#方法