A cluster singleton keeps exactly one actor instance across an Akka cluster. The instance runs on the oldest node, identified by the lower IP address, and relocates automatically when that node leaves the cluster. section 8.1 section 13.4
Use a singleton when the system needs one shared point of access, but account for its operational costs:
- Centralize a consistent value or service such as a global variable, cache, dictionary, authentication proxy, logger, scheduler, job manager, or file-system manager. section 13.4
- Expect downtime while the actor relocates after node removal; the singleton can become both a single point of failure and a bottleneck. section 13.4
- Remember that relocation loses in-memory state because the actor is not persistent; add persistence when state must survive movement. section 13.4
val singletonFactory = ClusterSingleton(system)
Create a singleton factory from the ActorSystem, wrap supervised behavior in a SingletonActor, and initialize it so repeated initialization still yields one cluster-wide instance. section 13.4
