2.2-M1 Spotlight: Cluster Singleton Pattern
Using a singleton should not be the first design choice, but for some use cases it is convenient and sometimes also mandatory to ensure that you have exactly one actor of a certain type running somewhere in the cluster.
This can be implemented by subscribing to LeaderChanged events, but there are several corner cases to consider. Therefore, this specific use case is made easily accessible by the Cluster Singleton Pattern in the contrib module.
The singleton actor is always running on the leader member, which is nothing more than the address currently sorted first in the member ring. This can change when adding or removing members. With the names given above the path of singleton actor can be constructed by subscribing to LeaderChanged cluster event and the actor reference is then looked up using actorFor:
Read more in the documentation.
2.2-M1 Spotlight: Startup when Cluster Size Reached
With a configuration option you can define required number of members before the leader changes status of ‘Joining’ members to 'Up’.
You can defer startup of actors until the cluster has at least the defined number of members.
Read more in the docs for Scala or in the docs for Java.
2.2-M1 Spotlight: Adaptive Load Balancing Based on Cluster Metrics
The member nodes of the cluster collects system health metrics, such as heap memory and CPU usage. The metrics is spread to other nodes and consumed by a new type of router that performs load balancing of messages to cluster nodes based on the cluster metrics data.
The router is defined in the same way as other routers:
and in this case it’s configured as follows:
Many thanks to Helena Edelson for her great contributions to the metrics design and implementation. In an upcoming blog post she will describe this topic in more detail.
Read more in the docs for Scala or in the docs for docs for Java.