Intro to Virtual Actors by Microsoft Orleans

Actor Model vs Virtual Actor Model

What is Microsoft Orleans

Why use Microsoft Orleans

Main concepts of Microsoft Orleans


  • identity
  • behavior
  • state


Microsoft Orleans Silo
  • scalability
  • fault-tolerance
Microsoft Orleans Cluster

Microsoft Orleans — major features


Timers & Reminders

Distributed ACID Transactions


  • the highest degree of availability because each node (silo) in the cluster can be used for serving data;
  • we can scale up and allow increasing the workloads because the nodes (silos) in the cluster can be used for doing parallel processing;
  • fast/instantaneous failure recovery due to the fact that multiple nodes )(silos) are storing an instance of our replicated grain.
  • consistent versioning: a grain can have multiple instances, each of them having a proprietary state that will be created using the same sequence of events. This implies the fact that if two grain instances are having the same version number, then they are having the same state;
  • racing events: an event can be raised by multiple grain instances and this will require resolving a race condition and an agreement for deciding on how the sequence of events should look like;
  • notifications/reactivity: a notification will be raised to all grain instances, whenever an event is raised by one specific grain instance.


  • automatic workload scalability because the data is partitioned across multiple cluster members and we can use those members in parallel for doing computations;
  • increased resilience and simplified recovery from failures achieved by using partition backups;
  • lower latency and less load on the data stores are achieved by keeping the grain state in memory while the grain is active.

Example project

  • clustering
  • persistence
  • client-server

High-level architecture

System’s components

  1. One component that will be instantiated for starting a new Microsoft Orleans Silo. You can find it here.
  2. One component that is containing the Microsoft Orleans Grains. This is basically the type-safe API by which we can communicate with the Microsoft Orleans cluster. You can check it out here.
  3. An HTTP Web API built by using .NET 6 minimal web API feature. This will allow triggering the operations of increment and decrement of the distributed counter.

Microsoft Orleans Grains

  • Microsoft.Extensions.Caching.Abstractions
  • Microsoft.Extensions.DependencyInjection
  • Microsoft.Extensions.Options
  • Microsoft.Orleans.Client
  • Microsoft.Orleans.CodeGenerator.MSBuild
  • Microsoft.Orleans.Core.Abstractions

Set() Method

Get(), Refresh() & Clear() Methods


The DistributedCounter extension

Microsoft Orleans Silo

  • Microsoft.Extensions.Hosting
  • Microsoft.Extensions.Logging
  • Microsoft.Orleans.Clustering.AdoNet
  • Microsoft.Orleans.Persistence.AdoNet
  • Microsoft.Orleans.Server
  • Orleans.AdoNet.SqlServer
  • System.Data.SqlClient

The database

The Microsoft Orleans Client and Web API

  • Microsoft.Orleans.Clustering.AdoNet
  • Swashbuckle.AspNetCore
  • System.Data.SqlClient


  • we learned what Microsoft Orleans is and what features it’s providing;
  • we saw how to create and use Microsoft Orleans Grains;
  • we created and used a Microsoft Orleans Silo and a Microsoft Orleans Client;
  • we integrated a persistent store into our solution and persisted the state of our grains into it.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Dina Bogdan

Dina Bogdan

Living in a reactive, full of actors, distributed system.