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
Follow the master’s stateful path from timed work generation through routing, result merging, and failed-job requeueing. section 8.4.3
