Akka.NET v1.4 is Available on .NET Standard 2.0
Akka.Remote Performance Improvements, Akka.Cluster.Sharding out of Beta, Akka.Cluster.Metrics, and More
As of this week, Akka.NET v1.4 is now fully available for users to use. We’ve published a detailed article on the Akka.NET website that describes what’s new in Akka.NET v1.4, but we wanted to capture some of the highlights here.
Akka.Cluster.Sharding and Akka.DistributedData are out of Beta
Akka.Cluster.Sharding has been used by Akka.NET users in production for years, mostly relying on the underlying Akka.Persistence storage engine to save all of the sharding state used to distributed entity actors evenly across the cluster.
However, the reason why the module remained in beta for the past couple of years is because Akka.Cluster.Sharding’s alternate storage mode, Akka.DistributedData, which uses eventually consistent in-memory replication to manage cluster sharding state throughout an Akka.NET cluster, lacked a stable wire format and hadn’t been certified for production yet.
We’ve resolved both of those issues in Akka.NET v1.4 - Akka.DistributedData and Akka.Cluster.Sharding are both available as stable modules in Akka.NET as of v1.4.
You can enable Akka.Cluster.Sharding with DData storage via the following configuration change:
akka.cluster.sharding.state-store-mode = "ddata"
New Module: Akka.Cluster.Metrics
This has been a long time coming, and we’ve released the first full version of it as a stable module: Akka.Cluster.Metrics.
The idea behind Akka.Cluster.Metrics is to make it easy to measure the busyness of each node individually throughout the cluster:
public class MetricsListener : ReceiveActor
{
private readonly ILoggingAdapter _log = Context.GetLogger();
private readonly Cluster _cluster = Cluster.Get(Context.System);
private readonly ClusterMetrics _metricsExtension = ClusterMetrics.Get(Context.System);
public MetricsListener()
{
Receive<ClusterMetricsChanged>(clusterMetrics =>
{
foreach (var nodeMetrics in clusterMetrics.NodeMetrics)
{
if (nodeMetrics.Address.Equals(_cluster.SelfAddress))
{
LogMemory(nodeMetrics);
LogCpu(nodeMetrics);
}
}
});
}
// Subscribe unto ClusterMetricsEvent events.
protected override void PreStart()
{
base.PreStart();
_metricsExtension.Subscribe(Self);
}
// Unsubscribe from ClusterMetricsEvent events.
protected override void PostStop()
{
base.PostStop();
_metricsExtension.Unsubscribe(Self);
}
private void LogMemory(NodeMetrics nodeMetrics)
{
Option<StandardMetrics.Memory> memory = StandardMetrics.ExtractMemory(nodeMetrics);
if (memory.HasValue)
_log.Info("Used memory: {0} Mb", memory.Value.Used / 1024 / 1024);
}
private void LogCpu(NodeMetrics nodeMetrics)
{
Option<StandardMetrics.Cpu> cpu = StandardMetrics.ExtractCpu(nodeMetrics);
if (cpu.HasValue)
_log.Info("Cpu load: {0}% ({1} processors)", cpu.Value.TotalUsage / 100, cpu.Value.ProcessorsNumber);
}
}
Akka.Cluster.Metrics also allows users to:
- Publish and subscribe custom node metrics;
- Implement clustered routers that use Akka.Cluster.Metrics data to route events towards the “least busy” nodes, and that’s defined according to the set of metrics you use.
Click here to read more about Akka.Cluster.Metrics.
Akka.Remote Performance Improvements
We have bigger long-term plans for improving Akka.Remote performance, but in Akka.NET v1.4 we reached a major milestone in guaranteeing more consistent and higher throughputs through the addition of an I/O batching system built-in to the DotNetty transport:
StreamRefs
- Akka.Streams that can Span the Network
You can read more about StreamRef
here, but the big idea is that they now allow AKka.NET users to compose streams that can span multiple nodes on the network.
NOTE: We’ll be posting a
StreamRef
tutorial later in Q2.
Platform Change: No More .NET Framework 4.5 Support; .NET Standard 2.0 Only
One of the biggest changes in Akka.NET v1.4 is that the framework no longer supports .NET Framework 4.5, which was marked as “end of life” by Microsoft many years ago.
Going forward we are only supporting .NET Standard 2.0, which supports .NET Framework 4.6.1+ and .NET Core 2.0+.
You can read the full list of changes and updates to Akka.NET in v1.4 here. We thank you for your continued support and patronage! Please upgrade and take advantage of these great new features.
If you liked this post, you can share it with your followers or follow us on Twitter!
- Read more about:
- Akka.NET
- Case Studies
- Videos
Observe and Monitor Your Akka.NET Applications with Phobos
Did you know that Phobos can automatically instrument your Akka.NET applications with OpenTelemetry?
Click here to learn more.