liveBook · Manning

Cluster singleton

As explained in Akka in Action, Second Edition

A cluster singleton is an actor pattern that maintains one actor instance across an entire cluster and relocates it after node failure.

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

How Akka in Action, Second Edition covers it

How deep it goes
Explains placement, relocation, downtime, bottlenecks, state loss, persistence, supervision, and initialization, but not persistence implementation.
Examples
Demonstrates caches, dictionaries, authentication proxies, loggers, schedulers, job managers, file managers, and a supervised Akka singleton.
What it assumes
Assumes an ActorSystem and actor behavior, while establishing cluster-wide uniqueness and node-failure relocation.
What you can do after
Apply it via Akka Cluster by defining behavior, wrapping supervision, and initializing one relocatable actor.
How it connects
Connects actors with supervision strategy, persistence, cluster sharding, distributed data, and split brain resolver.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Akka in Action, Second Edition. The section links point to the parts of the book it draws on.