Building Scalable Systems with Akka.NET

Akka.NET

An introduction to actor-based distributed systems

Aaron Stannard / October 14, 2025

## What We'll Cover 1. The Actor Model 2. Akka.NET Fundamentals 3. Building Distributed Systems 4. Real-World Patterns 5. Demo Note: This presentation covers the basics of Akka.NET and distributed systems patterns.

The Actor Model

A different way to think about concurrency

What is an Actor?

  • Lightweight computational unit
  • Processes messages asynchronously
  • Maintains internal state
  • Creates other actors
  • No shared memory - only messages

Actor Model Trade-offs

Pros

  • Simple concurrency model
  • Location transparency
  • Natural fault isolation
  • Scales horizontally

Cons

  • Learning curve
  • Different mental model
  • Debugging complexity

Akka.NET Fundamentals

Core concepts and APIs

A Simple Actor


public class GreeterActor : ReceiveActor
{
    public GreeterActor()
    {
        Receive<Greet>(greet =>
        {
            Console.WriteLine($"Hello {greet.Name}!");
            Sender.Tell(new Greeted(greet.Name));
        });
    }
}

Actors receive messages and respond asynchronously

Actor Messages


// Messages are simple immutable data types
public record Greet(string Name);
public record Greeted(string Name);

Messages define the actor's protocol

Creating and Using Actors


// Create an ActorSystem
var system = ActorSystem.Create("MySystem");

// Create an actor
var greeter = system.ActorOf<GreeterActor>("greeter");

// Send a message
greeter.Tell(new Greet("World"));

Actor Hierarchy

graph TD A[Actor System] --> B["/user"] B --> C[Parent Actor] C --> D[Child Actor 1] C --> E[Child Actor 2] E --> F[Child Actor 3] A --> G["/system"] style A fill:#42affa style B fill:#17b2c3 style C fill:#17b2c3

Supervision hierarchies provide fault tolerance

Building Distributed Systems

Clustering and remoting

Akka.Cluster

Features

  • Automatic node discovery
  • Leader election
  • Distributed data
  • Cluster sharding

Use Cases

  • Load balancing
  • High availability
  • Geographic distribution
  • Elastic scaling

Distributed Architecture

graph TB LB[Load Balancer] --> N1[Node 1] LB --> N2[Node 2] LB --> N3[Node 3] N1 --> DB[Distributed State] N2 --> DB N3 --> DB style LB fill:#42affa style N1 fill:#17b2c3 style N2 fill:#17b2c3 style N3 fill:#17b2c3
The actor model is not just about concurrency - it's about building resilient, distributed systems that can survive failures.

— Hewitt, Bishop, and Steiger (1973)

Real-World Patterns

Proven patterns for production systems

Common Akka.NET Patterns

Routing

Distribute work across actor pools

Circuit Breaker

Prevent cascading failures

Backpressure

Control message flow rates

Event Sourcing

Persist actor state as events

Router Pattern


var router = system.ActorOf(
    Props.Create<WorkerActor>()
        .WithRouter(new RoundRobinPool(5)),
    "worker-router");

// Messages are distributed across 5 workers
for (int i = 0; i < 100; i++)
{
    router.Tell(new Work(i));
}

Distribute work across a pool of actors

Demo

See it in action

Live Demo

Building a distributed chat system

With cluster sharding

And persistence

Resources

Thank You!

Questions?

https://aaronstannard.com
@aaronstannard