Search code examples
configurationdistributed-computingorleans

Microsoft Orleans maximum grains per silo


I am testing Microsoft Orleans for feasibility as a distributed computing framework. It seems like it may work however I was wondering how do I set the maximum number of active grains in a given silo?

My grains will not purely be CPU bound and will perform some IO and other related tasks. I am worried that if I let it run wild it will spin up a massive number of instances which will bog the whole thing down.

Is silo configuration like this possible?


Solution

  • Orleans is very well suited for non-CPU-bound work. Orleans grains are designed to use Task<T> for asynchrony instead of threads, so you should always perform asynchronous IO, using C#'s [async/await][1] feature.

    If you absolutely need to perform blocking IO, you can perform the IO outside the context of the grain and await the result in your grain, like so:

    var result = await Task.Run(() => {
      // Perform blocking work.
      return 43;
    });