Skip to content

AxonOps — AI-Native Control Plane for Open Source Data Platforms

nodetool compactionstats

Displays statistics about currently running compactions and pending compaction tasks.


Terminal window
nodetool [connection_options] compactionstats [-H]

See connection options for connection options.

nodetool compactionstats shows:

  • Currently active compaction operations
  • Progress of each compaction
  • Pending compaction tasks by keyspace
  • Compaction throughput

This is essential for monitoring compaction health and identifying backlogs.


OptionDescription
-H, --human-readableDisplay sizes in human-readable format
-V, --vtableUse virtual table format for output

pending tasks: 15
- my_keyspace.users: 8
- my_keyspace.orders: 7
id compaction type keyspace table completed total unit progress
abc123-def4-... Compaction my_keyspace users 1234567890 2345678901 bytes 52.65%
def456-abc7-... Compaction my_keyspace orders 567890123 1234567890 bytes 46.01%
ghi789-jkl0-... Validation my_keyspace users 45678901 123456789 bytes 37.00%
Active compaction remaining time : 0h12m34s

Note: The output includes pending tasks broken down by keyspace and table, plus a per-compaction id column (unless -V/--vtable is used).


FieldDescription
pending tasksTotal compaction tasks waiting to run (with per-keyspace.table breakdown)
idUnique identifier for the active compaction operation
compaction typeType of operation (Compaction, Validation, Cleanup, etc.)
keyspaceKeyspace being compacted
tableTable being compacted
completedBytes processed so far
totalTotal bytes to process
unitUnit of measurement
progressPercentage complete
TypeDescription
CompactionRegular SSTable compaction
ValidationBuilding Merkle tree for repair
CleanupRemoving data not owned by node
ScrubRebuilding corrupted SSTables
UpgradeUpgrading SSTable format
Index_buildBuilding secondary index
AnticompactionSplitting SSTables for incremental repair

pending tasks: 0
Active compaction remaining time : n/a

No active compactions and no backlog.

pending tasks: 3
compaction type keyspace table completed total unit progress
Compaction my_keyspace users 1234567890 2345678901 bytes 52.65%
Active compaction remaining time : 0h05m23s

Normal operation with manageable workload.

pending tasks: 150
compaction type keyspace table completed total unit progress
Compaction my_keyspace users 1234567890 2345678901 bytes 52.65%
Active compaction remaining time : 2h45m12s

High Pending Tasks

Large pending task count indicates:

  • Writes exceeding compaction capacity
  • Insufficient compaction throughput
  • Need to tune compaction settings

Actions:

  • Increase compaction throughput
  • Add more concurrent compactors
  • Reduce write rate if possible
  • Review compaction strategy
pending tasks: 10
compaction type keyspace table completed total unit progress
Compaction my_keyspace users 1234567890 2345678901 bytes 52.65%
Compaction my_keyspace orders 567890123 1234567890 bytes 46.01%
Compaction other_ks events 123456789 234567890 bytes 52.63%
Compaction other_ks logs 234567890 345678901 bytes 67.95%

Multiple concurrent compactors running (controlled by concurrent_compactors).


Terminal window
# Periodic check
nodetool compactionstats
# Continuous monitoring
watch -n 5 'nodetool compactionstats'

Monitor for backlog buildup:

Terminal window
watch -n 2 'nodetool compactionstats | head -5'

Validation compactions appear during repair:

Terminal window
nodetool compactionstats | grep Validation

After bulk loads or migrations:

Terminal window
# Watch compaction catch up
watch -n 10 'nodetool compactionstats'

Terminal window
nodetool compactionstats
Terminal window
nodetool compactionstats -H

Output:

pending tasks: 15
compaction type keyspace table completed total unit progress
Compaction my_keyspace users 1.2 GB 2.3 GB bytes 52.65%
Terminal window
nodetool compactionstats | head -1
Terminal window
watch -n 5 'nodetool compactionstats -H'
Terminal window
for node in node1 node2 node3; do
echo "=== $node ==="
ssh "$node" "nodetool compactionstats | head -3"
done

Terminal window
# Check current throughput
nodetool getcompactionthroughput
# Increase throughput (MB/s)
nodetool setcompactionthroughput 256
Terminal window
# Check current setting
nodetool getconcurrentcompactors
# Increase (use cautiously)
nodetool setconcurrentcompactors 4

Concurrent Compactors

More compactors = more parallel I/O. Only increase if disk can handle it.

Terminal window
# Stop current compactions (for emergency)
nodetool stop COMPACTION
# Better: Stop specific types
nodetool stop INDEX_BUILD

pending tasks: 150

Pending tasks accumulate when:

CauseSolution
High write rateIncrease throughput/compactors
Large SSTablesTune compaction strategy
Slow disksImprove I/O capacity
Repairs runningNormal during repair
Insufficient threadsIncrease compactors
Terminal window
# See which tables have pending compactions
nodetool compactionstats -H

Tables with consistently high pending may need:

  • Different compaction strategy
  • More frequent cleanup
  • Data model review

Terminal window
nodetool getcompactionthroughput
Terminal window
# Increase to 256 MB/s
nodetool setcompactionthroughput 256
# Unlimited (not recommended)
nodetool setcompactionthroughput 0

Throughput Guidelines

  • Default: 64 MB/s
  • SSD clusters: 256-512 MB/s
  • HDD clusters: 64-128 MB/s
  • Monitor disk utilization when increasing

Terminal window
# Check every minute
while true; do
echo "$(date): $(nodetool compactionstats | head -1)"
sleep 60
done

If pending continuously increases, action required.

Compactions running for hours may indicate:

  • Very large SSTables
  • Slow disk I/O
  • Memory pressure (GC during compaction)

Check with system tools:

Terminal window
top -p $(pgrep -f CassandraDaemon)

Compression/decompression is CPU-intensive.


CommandRelationship
getcompactionthroughputCheck throughput setting
setcompactionthroughputAdjust throughput
compactForce compaction
tablestatsSSTable counts per table