One of the questions that has been coming up a lot lately as many people are building with Akka.Remote is this:

How big of a message can I send over the network?

I’ve been asked about this four or five times this week alone, so it’s time to put out a blog post and stop re-writing the answer. This is a great question to cover, as it starts to reveal more about what is going on under the hood with Akka.Remote and the networking layer.

Up until I worked on Akka.NET, I honestly hadn’t thought much about the networking layer and so this was a fun question for me to dig into and research.

When Does This Come up?

This comes up all the time when people have large chunks of data that they need to transmit and process. I’ve been asked about this lately in the context of doing big ETL jobs, running calculations on lab data, web scraping, for video processing, and more. People asking about sending files that range anywhere from 20MB to 5GB.

All of these contexts involve large amounts of data that need to be processed, but no clear way to link that up with the distributed processing capabilities that Akka.NET provides.

So what’s a dev to do?

Here’s the first answer people try: “network-shmetwork! JUST SEND IT!”

Why This Is A Bad Idea

This is basically what that does to the network:

Python eating an entire pig

That is a python trying to eat an entire pig. Ewwwww. Gross.

If it could feel, that’s how the network would feel about our large messages.

What else do people try to do? Here are some of the common approaches I’ve seen:

  • crank up...

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.