Database / Apache Cassandra Intermediate and Advanced interview questions
What is nodetool cleanup used for?
nodetool cleanup removes data that a node is no longer responsible for, reclaiming disk space after the cluster's token ownership has changed.
- When a new node joins (or an existing node's token ranges otherwise shift), other nodes may keep serving reads/writes correctly for a while, but they still physically hold on-disk data for ranges they've handed off, until cleanup removes it.
- Cleanup rewrites SSTables, discarding rows whose partition key hashes to a token range the node no longer owns.
- It is not run automatically — operators must trigger it manually on the affected nodes after a topology change like adding nodes.
- Cleanup can be I/O and CPU intensive, so it's typically throttled (
nodetool setcompactionthroughput-style controls apply similarly) and run during low-traffic windows, one node at a time.
nodetool cleanup my_keyspace
Skipping cleanup after scaling a cluster doesn't cause correctness problems by itself, but it does waste disk space indefinitely, since the orphaned data just sits there unused until cleanup (or a future compaction that happens to touch those SSTables) removes it.
More Related questions...