liveBook · Manning

Master

As explained in Akka in Action, Second Edition

A master is an application actor that coordinates worker actors, sends them processing tasks, and aggregates their results.

A master is an actor that coordinates distributed job processing. It produces or receives work, delegates each job to workers on other cluster nodes, and keeps only the combined result. In a word-counting service, workers count words in individual texts while the master maintains the running total, separating parallel processing from aggregation. section 8.4

A director node creates the master and a group router after the cluster reaches Up status. Worker actors run on aggregator nodes, register under a shared registration key, and become discoverable through that router. Delaying master startup until the required worker-node count is available prevents it from running before it has capacity to delegate work. section 8.4.2 section 8.4

A master’s working loop is:

  • Schedule a periodic Tick and add newly generated text to a lag queue. section 8.4.3
  • Take up to the configured delegation-parallelism from lag and send each text through the worker router using ask requests with a three-second timeout. section 8.4.3
  • Receive a successful word-frequency map as CountedWords, merge it into accumulated state, and continue working. section 8.4.3
  • Receive FailedJob for an unsuccessful request and return its original text to lag for later reprocessing. section 8.4.3

Clustered word-count master

With four aggregator nodes running five workers each, a delegation parallelism of 20 can keep all 20 workers occupied. Every second, the master creates a sample text, routes work at random, and merges returned Map[String,Int] values. Runtime output exposes operational state: lag is zero while workers are available, and the current count grows as responses arrive. section 8.4.3 section 8.4.1

Figure 8.13 Master business flow
CH08_F13_Abraham2

Follow the master’s stateful path from timed work generation through routing, result merging, and failed-job requeueing. section 8.4.3

How Akka in Action, Second Edition covers it

How deep it goes
Works through timer-driven batching, ask timeouts, state merging, and lag-based retry; defers serialization details.
Examples
Uses a multi-node word-count application, lag and count logs, and director, seed, and aggregator startup commands.
What it assumes
Assumes basic actor and cluster setup while explaining role-based startup, worker registration, and delegation flow.
What you can do after
Build it from scratch as a stateful actor that delegates bounded batches, merges results, and requeues failed jobs.
How it connects
Connects actor messaging, cluster roles, group routers, service discovery, ask requests, and serialization.

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.