Reputation: 533
I am quite new to using Cassandra and have a basic question that I was seeking an answer to. I am using the default compaction strategy which the Size-Tiered. I am aware that this can be changed to the Levelled Compaction strategy by running a command like this:
ALTER TABLE users WITH
compaction = { 'class' : 'LeveledCompactionStrategy' }
I am however unsure if this change takes into effect at runtime on a particular keyspace, or if I would need to restart the node for the changes to take effect. I read in the Datastax documentation (http://www.datastax.com/documentation/cassandra/1.2/cassandra/configuration/configCassandra_yaml_r.html) that changes to global configurations in the cassandra.yaml file only takes effect after a node is restarted and would like to know if the same applies for the keyspace specific properties like compaction strategy as well.
Thanks in advance for your help.
Upvotes: 6
Views: 6318
Reputation: 1174
You can modify compaction strategy online for sure. Cassandra will recompact all sstables, so only concern is disk I/O. pre-2.1, the old sstable is replaced only after the new sstable is created. after 2.1, new sstable can serve traffic during the creation (mainly to preserve page cache, refer CASSANDRA-6916). so basically, your traffic will not be affected.
I know some companies, e.g, netflix perform this change via jmx host by host to prevent cluster-wide thundering storm. But I don't see any issue with ALTER TABLE
for our cluster.
Upvotes: 0
Reputation: 57808
The newer documentation on configuring compaction indicates that the correct procedure to enable Leveled Compaction is the ALTER TABLE
statement that you have above. While you are correct that changes to the cassandra.yaml
file will require a node(s) restart to take effect, table configuration changes typically do not. It should use Leveled Compaction for that table the next time compaction is triggered.
Additionally, you should read through Tyler Hobbs' article titled When to Use Leveled Compaction. Since you are new to Cassandra, give that a look just to be sure you have an appropriate use case.
Upvotes: 3