question

Cedrick Lunven avatar image
Cedrick Lunven asked Cedrick Lunven answered

Token ranges definitions based on num_tokens ?

While bootstrapping, the node generates vnode token ranges based on num_tokens:

1. Is token range size is fixed or not ?

2. How nodes know token ranges assigned to other nodes?

3. Is Cassandra storing hash value of partition key along with record?

virtual nodes
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Cedrick Lunven avatar image
Cedrick Lunven answered

1. Is token range size is fixed or not ?

It is not fixed.

The token range is between -2^63 to +2^63 -1 and num_token defines how many token ranges are assigned to a node. Token range size are related to the number of node in the cluster => The more nodes you have, the smaller the range size is.


Here is a sample:

Consider 2 nodes with num_tokens set to 4 and token range 0 to 100.

- Node 1 calculates tokens 17, 35, 77, 92

- Node 2 calculates tokens 4, 25, 68, 85

The ring shows the distribution of token ranges in this case Node 2 is responsible for token ranges 4-17, 25-35, 68-77, 85-92 and node 1 for the rest.


2. How nodes know token ranges assigned to other nodes?

This is part of the gossiping protocol, they exchanged the tokens they computed and token ranges.

The token ranges are part of the Cassandra API and protocol and you can alaos retrieve them with the API : https://docs.datastax.com/en/developer/java-driver/4.7/manual/core/metadata/token/


3. Is Cassandra storing hash value of partition key along with record?


There are indeed stored. All all levels of the read path Bloom filter, Partition index, partitions summaries and SSTABLE tokens are use to locate the data

https://cassandra.apache.org/doc/latest/tools/sstable/sstablemetadata.html


Also @Erick Ramirez gave some extra information relative to token ranges here :

https://community.datastax.com/questions/4907/token-range-in-single-node-cluster-without-vnodes.html

Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.