Just the other day, I saw this tweet and knew this post was long overdue:

Quite understandably, people want to know what the design patterns in Akka.NET are! There are quite a few-our team has cataloged 30+ across various areas of the framework so far-but there is also that rarefied set of patterns that show up again, and again, and again.

These patterns cover four broad categories:

  1. Actor Composition
  2. Messaging
  3. Reliability
  4. Testability

Let’s get going.

Actor Composition Patterns

“Actor Composition” patterns are used to create groups of interrelated actors in order to accomplish specific goals. Patterns of this type help you think about how many actors you need, and how to structure the relationships between them in your hierarchy.

These patterns are aimed at allowing you to use Akka.NET’s supervision hierarchy to your advantage in order to achieve maximum reliability and transparency when working with actors. They will also make your architecture more intuitive.

Composition Pattern: Child-Per-Entity

The Child-per-Entity pattern occurs whenever some /parent actor is responsible for a domain of entities and elects to represent each entity as its own actor. The parent maintains a mapping to know which child actor corresponds with which domain entity. The /parent can then lookup/create/kill child actors as domain object enter or leave its going concerns.

One of the most powerful ways to use Akka.NET in production is to create clustered applications that can scale on-demand. You can literally deploy code somewhere other than the immediate, local process making the call.

And the way this is accomplished is with the Akka.Cluster module. AkkaCluster is the module that adds clustering capabilities to our Akka.NET applications.

When do I need clustering?

Clustering is something you need to use in high availability scenarios, or when you need elastic scalability in your systems.

Here are some examples of high availability scenarios that come up often in the real-world, and these are projects that often use clustering!

  • Analytics
  • Marketing Automation
  • Multiplayer Games
  • Devices Tracking / Internet of Things
  • Alerting & Monitoring Systems
  • Recommendation Engines
  • Dynamic Pricing
  • …and many more!

As you can see, clustering has a wide-range of use cases, and it’s also the way to create a scalable microservices architecture in Akka.NET. To put it bluntly, you should use clustering in any scenario where you have:

  • A sizable load of traffic;
  • With non-trivial work that has to be performed;
  • And an expectation of fast response times;
  • And frequent mutation in state.

How Do I Form a Cluster of Services?

After you’ve enabled Akka.Cluster inside your Akka.NET application, it’s easy to make your locally developed application cluster over the network.

Today we shipped Akka.NET v1.0.2, a maintenance release that fixed a number of bugs as well as introduced some exciting new features.

Major Akka.Cluster Stability Upgrades

Akka.Cluster is still in beta at the moment, but we’re on target for a full Akka.Cluster release in Akka.NET v1.1.

In this release we had some new contributors emerge from the ranks of Akka.NET’s production users to deliver some major stability upgrades to Akka.Cluster. We fixed critical issues in the following areas:

  • Leader election algorithm;
  • Clustered group routers;
  • Akka.Remote and Akka.Cluster dispatchers now run on their own dedicated thread pools; and
  • Akka.NET scheduler now runs on its own dedicated thread by default.

These changes resulted in massive improvements in cluster stability and reliability for these customers, and has helped put us on track towards our goal of a stable Akka.Cluster release in the near future.

New Akka.Persistence Plugins

If you’re interested in Akka.Persistence, things just became a lot more interesting! In the previous Akka.NET release (v1.0.1) we shipped Akka.Persistence.SQLServer (docs) (NuGet.)

In Akka.NET v1.0.2 we’ve added two new backing stores for Akka.Persistence:

Akka.Persistence is still in beta, but it’s one of the most exciting libraries in Akka.NET due to its ability to add guaranteed delivery and event sourcing to actors with high consistency requirements.

Other New Features

In addition to the above changes, we’ve also added the following additional packages to Akka.NET:

Akka.DI.StructureMap Akka.NET’s dependency injection system now supports StructureMap! You can install Akka.DI.StructureMap via the NuGet commandline:

PM> Install-Package Akka.DI.StructureMap 

Akka.TestKit.XUnit2 Akka.NET now has support for XUnit 2.0! You can install Akka.TestKit.XUnit2 via the NuGet commandline:

PM> Install-Package...