liveBook · Manning

Token

As explained in ScyllaDB in Action

A token is a value used to determine a data partition's placement and ownership in a distributed database cluster.

A token is an integer position on a hash ring. ScyllaDB hashes each partition key to a token, placing rows with the same partition key together and assigning responsibility for that position to a node. section 3.3.1

Nodes claim token ranges around the ring, often through multiple virtual-node positions. When a node joins, it takes portions of existing ranges, and other nodes stream those rows to the new owner. section 3.3.1

During reads and inserts, ScyllaDB hashes the partition key, determines the applicable token, and forwards the request to the node that owns it. The TOKEN function exposes a partition's ring position. section 8.2.1

Inspecting a token

Use TOKEN(id) in cqlsh to display the ring position associated with each partition-key value: SELECT TOKEN(id), id FROM reviews.authors; section 8.2.1

Figure 3.8 Partitions are mapped to places on a hash ring.
figure

A hash-ring figure makes the relationship between partition placement and token positions visible. section 3.3.1

How ScyllaDB in Action covers it

How deep it goes
Explains hashing, ring positions, vnode ownership, node joining, request routing, and TOKEN inspection without formal mathematics.
Examples
Uses hash-ring diagrams, vnode ownership illustrations, cluster status output, and a cqlsh TOKEN query.
What it assumes
Assumes partition keys and hashing, then connects them to distributed placement and ownership.
What you can do after
Apply the TOKEN function to inspect a partition key's ring position and trace which node owns its slice.
How it connects
Connects partition keys, hash rings, virtual nodes, replication factors, consistency options, and distributed data ownership.

Related concepts

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