orleans

What is the scope of Orleans grains that are created on the client with the key Guid.Empty?


According to the Microsoft doc Grain Identity, I can get a singleton grain instance by using the key Guid.Empty on the client.

Will this singleton grain instance be scoped globally, to the cluster, or to the silo?


Solution

  • According to the official docs:

    Orleans ensures that when a grain call is made there is an instance of that grain available in memory on some server in the cluster to handle the request. If the grain is not currently active in the cluster, Orleans picks one of the servers to activate the grain on. This is called grain placement. Placement is also one way that load is balanced: even placement of busy grains helps to even the workload across the cluster.

    Meaning, you can specify where the Grains are placed when created/called.

    You can read more here: https://learn.microsoft.com/en-us/dotnet/orleans/grains/grain-placement