What is the actor model in C# with Akka.NET or Orleans?
Answer
The Actor Model is a concurrency paradigm where the basic unit of computation is an "actor" — an isolated entity that communicates exclusively via asynchronous messages, maintains private state, and can create child actors. No shared mutable state between actors eliminates many concurrency issues. Akka.NET: a port of the Scala Akka framework. Actors inherit from ReceiveActor and define message handlers: Receive<string>(msg => sender.Tell($"Echo: {msg}"));. Support for supervision strategies (fault tolerance), routing, clustering, persistence. Microsoft Orleans: Microsoft's virtual actor framework (originally for Halo). Actors are called "grains" — virtual, addressable by ID, automatically activated on demand. Grains use persistent state and are distributed across a cluster transparently. Used by Skype, Xbox, and Azure services. Actor model excels at: distributed systems, game backends, IoT telemetry, state machines. Compared to async/await: better for long-lived stateful entities and when explicit concurrency control is needed.
Previous
What is the Roslyn compiler API?
Next
What is GC pressure and how do you diagnose and fix it?