Microsoft Orleans, a .NET framework for building scalable distributed cloud applications, has been updated for .NET 7 and released as Orleans 7.0.0 on November 8th, 2022. The improvements in this release include better performance, simplified development dependencies, and a simplified identification schema for the grains, a unit of execution in Orleans.
Orleans started in 2010 as a project inside Microsoft Research around virtual actors, an abstraction over the actor model of computation. It was then used as the technology of choice for building the Microsoft Azure back-end for the popular game franchise Halo. The core technology behind Orleans was transferred to 343 Industries, a Microsoft Xbox Game Studios subsidiary, and it was made available as an open-source project on GitHub in 2015. Another actor-based programming framework, comparable to Orleans, is Akka.
In Orleans, the desired distributed functionality is modelled as a grain, an addressable unit of execution that can send and receive messages to other grains and maintain its own state if necessary. The grains are virtual actors, persisted to durable storage and activated in memory on demand, in the same sense as virtual memory is an abstraction over a computer's physical memory.
The grains had to inherit from the Grain base class in the previous versions of Orleans. Now the grains can be POCO objects. To get access to the code previously available only inside the Grain class, they can now implement the IGrainBase interface instead.
The Orleans runtime keeps track of the activation/deactivation and finding/invoking grains as necessary. It also keeps clusters of silos, the containers for the execution of grains. The communication with the Orleans runtime is done using the client library.
The last Orleans major version before 7.0 was version 3.0, released in 2019. The planned 4.0 release was later ported to .NET 7 and renamed to 7.0 to match the broader .NET 7 ecosystem launches.
Version 7.0.0 claims significant performance benefits over version 3, between 40% and 140%, across different machine configurations and scenarios. The Orleans source code includes a benchmarking application that Microsoft used to measure those improvements.
The development experience is improved by reducing the number of NuGet packages that are needed to be referenced, leaving three major rolled-up packages: one for the client projects, one for the server projects, and one for the abstractions and SDK. These packages then reference the needed individual Orleans packages. For comparison, NuGet lists 77 Orleans packages at the moment.
Another major improvement in Orleans 7.0.0 involves a simplified identification schema. In the previous version of Orleans, the grains could have a compound grain key. For example, one grain could use long
data type as a key type while another grain could use a Guid
with a string
. It made the code calling the grains by their identifier cumbersome. In 7.0.0, the grains have an identity in the form of type/value where both type and value are strings.
The new identification schema and the new serialisation mechanism that is more version-tolerant are the reasons why Orleans 7.0.0 hosts won’t be able to coexist with Orleans 3.X hosts in the same cluster. Microsoft claims that the changes were needed to simplify and generalise some cumbersome aspects of Orleans and that the version jump to .NET 7 was the perfect opportunity to do those tough choices. The official recommendation is to deploy a new cluster and gradually decommission the old one.
For a deeper understanding of how an Orleans application looks like, there is a sample text adventure game on GitHub that is designed for scale and showcases how to model a game in Orleans and how to connect an external client (a game client) to the Orleans cluster. While most of Orleans samples are modelled around games, Orleans can be used for various distributed computation problems, from managing an IoT network of connected water heaters to removing the database as a bottleneck in calculations.