Working with partitioners in Amazon Keyspaces - Amazon Keyspaces (for Apache Cassandra)

Working with partitioners in Amazon Keyspaces

In Apache Cassandra, partitioners control which nodes data is stored on in the cluster. Partitioners create a numeric token using a hashed value of the partition key. Cassandra uses this token to distribute data across nodes. Clients can also use these tokens in SELECT operations and WHERE clauses to optimize read and write operations. For example, clients can efficiently perform parallel queries on large tables by specifying distinct token ranges to query in each parallel job.

Amazon Keyspaces provides three different partitioners.

Murmur3Partitioner (Default)

Apache Cassandra-compatible Murmur3Partitioner. The Murmur3Partitioner is the default Cassandra partitioner in Amazon Keyspaces and in Cassandra 1.2 and later versions.

RandomPartitioner

Apache Cassandra-compatible RandomPartitioner. The RandomPartitioner is the default Cassandra partitioner for versions earlier than Cassandra 1.2.

Keyspaces Default Partitioner

The DefaultPartitioner returns the same token function results as the RandomPartitioner.

The partitioner setting is applied per Region at the account level. For example, if you change the partitioner in US East (N. Virginia), the change is applied to all tables in the same account in this Region. You can safely change your partitioner at any time. Note that the configuration change takes approximately 10 minutes to complete. You do not need to reload your Amazon Keyspaces data when you change the partitioner setting. Clients will automatically use the new partitioner setting the next time they connect.

You can change the partitioner by using the AWS Management Console or Cassandra Query Language (CQL).

AWS Management Console
To change the partitioner using the Amazon Keyspaces console
  1. Sign in to the AWS Management Console, and open the Amazon Keyspaces console at https://console.aws.amazon.com/keyspaces/home.

  2. In the navigation pane, choose Configuration.

  3. On the Configuration page, go to Edit partitioner.

  4. Select the partitioner compatible with your version of Cassandra. The partitioner change takes approximately 10 minutes to apply.

    Note

    After the configuration change is complete, you have to disconnect and reconnect to Amazon Keyspaces for requests to use the new partitioner.

Cassandra Query Language (CQL)
  1. To see which partitioner is configured for the account, you can use the following query.

    SELECT partitioner from system.local;

    If the partitioner hasn't been changed, the query has the following output.

    partitioner -------------------------------------------- com.amazonaws.cassandra.DefaultPartitioner
  2. To update the partitioner to the Murmur3 partitioner, you can use the following statement.

    UPDATE system.local set partitioner='org.apache.cassandra.dht.Murmur3Partitioner' where key='local';
  3. Note that this configuration change takes approximately 10 minutes to complete. To confirm that the partitioner has been set, you can run the SELECT query again. Note that due to eventual read consistency, the response might not reflect the results of the recently completed partitioner change yet. If you repeat the SELECT operation again after a short time, the response should return the latest data.

    SELECT partitioner from system.local;
    Note

    You have to disconnect and reconnect to Amazon Keyspaces so that requests use the new partitioner.