liveBook · Manning

Hash function

As explained in Akka in Action, Second Edition

A hashing algorithm is an algorithm that deterministically maps input data to hash values.

A hash function turns a message key into a hash code that helps a consistent-hashing router select a virtual node and its routee. Similar messages therefore follow the same routing path when they share a key. section 6.3.4 section 6.3.4

Consistent-hashing routing proceeds through these steps:

  • Extract a stable String key from the message, such as its ID, using a message-specific mapping function. section 6.3.4
  • Create a hash code from that key and use it to select a virtual node. section 6.3.4
  • Send the message to the routee responsible for that virtual node; virtual nodes improve distribution and support route changes. section 6.3.4

Routing messages by ID

Define mapping(command) = command.id, then configure an Akka group router with consistent hashing. Messages carrying the same ID produce the same hash and reach the same routee.

How Akka in Action, Second Edition covers it

How deep it goes
Explains key extraction, hashing, virtual-node selection, and routee selection, while leaving Akka internals invisible to normal users.
Examples
Uses command IDs, an Aggregator protocol, and Akka Scala configuration with ServiceKey and a group router.
What it assumes
Assumes messages expose comparable keys and requires implementing message-specific key extraction.
What you can do after
Apply Akka consistent-hashing routing by defining a stable message-key mapping and configuring virtual-node capacity.
How it connects
Connects message keys, mapping functions, consistent hashing, virtual nodes, routees, and group routers.

Also explained in

Compare how 16 books explain hash function →

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.