Partitioners

A partitioner determines how data is distributed across the nodes in the cluster, including replicas. A partitioner is a function for deriving a token representing a partition key, typically by hashing. Each row of data is then distributed across the cluster by the value of the token. You can use any IPartitioner, including your own, as long as it is in the classpath.

The default Murmur3Partitioner uses tokens to help assign equal portions of data to each node and evenly distribute data from all the tables throughout the ring or other grouping, such as a keyspace. This is true even if the tables use different partition keys, such as user names or timestamps. Because each part of the hash range receives an equal number of partitions on average, the read and write requests to the cluster are evenly distributed and load balancing is simplified. For more information, see Consistent hashing.

Whether you need assign tokens to each node depends on the type of architecture:

  • Virtual nodes: Use either the allocation algorithm or the random selection algorithm to specify the number of tokens distributed to nodes within the datacenter. All systems in the datacenter must use the same algorithm.

  • Single-token architecture: To ensure data is evenly divided across the nodes in the cluster, you must enter values in the initial_token parameter in cassandra.yaml on each node.

Murmur3Partitioner (default)

Uniformly distributes data across the cluster based on MurmurHash hash values. This hashing function creates a 64-bit hash value of the partition key with a possible range from -263 to +263-1. This partitioner is the right choice for new clusters in almost all cases and is 3 to 5 times more performant than the RandomPartitioner.

When using this partitioner, you can page through all rows using the TOKEN() function in a CQL query.

Murmur3Partitioner is the right choice and is recommended for new clusters.

The legacy partitioners are only included for backwards compatibility.

RandomPartitioner

Uniformly distributes data evenly across the nodes using an MD5 hash value of the row key. The possible range of hash values is from 0 to 2127 -1. Because it uses a cryptographic hash, which isn’t required by the database, it takes longer to generate the hash value than the Murmur3Partitioner.

When using this partitioner, you can page through all rows using the TOKEN() function in a CQL query.

RandomPartitioner is a legacy partitioner.

ByteOrderedPartitioner

This partitioner orders rows lexically by key bytes. It is not recommended because it requires significant administrative overhead to load balance the cluster, sequential writes can cause hot spots, and balancing for one table can result in uneven distribution for another table in the same cluster.

ByteOrderedPartitioner is a legacy partitioner.

The partitioner is configured in the cassandra.yaml file.

When you change the partitioner on a cluster, it makes existing records inaccessible and leads to data loss. You must reload all the data from another source, such as snapshots.

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com