Skip to content

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

nodetool getconcurrentcompactors

Displays the number of concurrent compactor threads.


Terminal window
nodetool [connection_options] getconcurrentcompactors

See connection options for connection options.


nodetool getconcurrentcompactors shows the current number of threads available for concurrent compaction operations. Each compactor thread can process one compaction task at a time, allowing multiple compactions to run in parallel when multiple threads are available.

What Are Concurrent Compactors?

Compactors are background threads that merge SSTables, remove tombstones, and consolidate data. More compactors enable faster compaction throughput but consume more CPU and I/O resources. See setconcurrentcompactors for detailed explanation.


Terminal window
nodetool getconcurrentcompactors

Sample output:

Current concurrent compactors: 4
check_compactors_cluster.sh
#!/bin/bash
echo "=== Concurrent Compactors Across Cluster ==="
# Get list of node IPs from local nodetool status
nodes=$(nodetool status | grep "^UN" | awk '{print $2}')
for node in $nodes; do
value=$(ssh "$node" "nodetool getconcurrentcompactors" 2>/dev/null | grep -oP '\d+')
echo "$node: $value compactors"
done

Sample output:

=== Concurrent Compactors Across Cluster ===
192.168.1.101: 4 compactors
192.168.1.102: 4 compactors
192.168.1.103: 4 compactors

If not explicitly configured, Cassandra calculates the default using the following formula:

concurrent_compactors = min(8, max(2, min(number_of_cpu_cores, number_of_data_directories)))

This ensures a minimum of 2 compactors and a maximum of 8, bounded by available CPU cores and data directories.

HardwareExpected Default
8 cores, 1 disk2 (minimum)
8 cores, 4 disks4
16 cores, 8 disks8 (maximum)
4 cores, 8 disks4
1 core, 1 disk2 (minimum)
ValueIndicatesTypical Reason
1Minimal parallelismSingle disk or resource-constrained
2-4Moderate parallelismBalanced configuration
5-8High parallelismMultiple disks, write-heavy workload
8+Maximum parallelismLarge JBOD, bulk loading

When compaction appears slow:

Terminal window
# Check compactor count
nodetool getconcurrentcompactors
# Compare with pending tasks
nodetool compactionstats | head -10
# If many pending tasks and few compactors, consider increasing

Before changing workload:

Terminal window
# Current compactors
nodetool getconcurrentcompactors
# Current hardware capacity
echo "CPU cores: $(nproc)"
echo "Data directories: $(grep -A 10 'data_file_directories:' /etc/cassandra/cassandra.yaml | grep '^ *-' | wc -l)"
# Current compaction throughput
nodetool getcompactionthroughput

Verify cluster consistency:

audit_compactors.sh
#!/bin/bash
echo "Auditing compactor settings..."
# Check runtime values
echo ""
echo "Runtime values:"
# Get list of node IPs from local nodetool status
for node in $(nodetool status | grep "^UN" | awk '{print $2}'); do
runtime=$(ssh "$node" "nodetool getconcurrentcompactors" 2>/dev/null | grep -oP '\d+')
echo " $node: $runtime"
done
# Check config file (local node)
echo ""
echo "Config file (local):"
grep concurrent_compactors /etc/cassandra/cassandra.yaml || echo " Not set (using default)"

Total Compaction Capacity ≈ concurrent_compactors × compaction_throughput_mb_per_sec
CompactorsThroughput SettingTotal Capacity
264 MB/s~128 MB/s
464 MB/s~256 MB/s
864 MB/s~512 MB/s
check_compaction_health.sh
#!/bin/bash
echo "=== Compaction Health Check ==="
# Current setting
compactors=$(nodetool getconcurrentcompactors | grep -oP '\d+')
echo "Concurrent compactors: $compactors"
# Pending tasks
pending=$(nodetool compactionstats | grep "pending tasks" | grep -oP '\d+')
echo "Pending compaction tasks: $pending"
# Assessment
if [ "$pending" -gt 100 ]; then
echo ""
echo "WARNING: High pending tasks. Consider:"
echo " nodetool setconcurrentcompactors $((compactors + 2))"
elif [ "$pending" -lt 10 ]; then
echo ""
echo "OK: Compaction keeping up"
else
echo ""
echo "MONITOR: Moderate backlog"
fi

SourceWhat getconcurrentcompactors Shows
After startup (no changes)Value from cassandra.yaml or calculated default
After setconcurrentcompactorsRuntime-modified value
After restartValue from cassandra.yaml (runtime changes lost)
Terminal window
# Runtime (active) value
nodetool getconcurrentcompactors
# Configured (persistent) value
grep concurrent_compactors /etc/cassandra/cassandra.yaml

If these differ, someone used setconcurrentcompactors to change the runtime value.

cassandra.yaml
# Number of simultaneous compactions to allow
# Comment out or omit for auto-calculated default
concurrent_compactors: 4

Possible causes:

  • Explicitly set low in cassandra.yaml
  • Single data directory configured
  • Few CPU cores
Terminal window
# Check why value is low
echo "CPU cores: $(nproc)"
grep data_file_directories -A 5 /etc/cassandra/cassandra.yaml
grep concurrent_compactors /etc/cassandra/cassandra.yaml

Possible causes:

  • Different hardware configurations
  • Manual runtime changes not persisted
  • Inconsistent cassandra.yaml
Terminal window
# Standardize across cluster
TARGET=4
# Get list of node IPs from local nodetool status
for node in $(nodetool status | grep "^UN" | awk '{print $2}'); do
ssh "$node" "nodetool setconcurrentcompactors $TARGET"
done
# Update cassandra.yaml on all nodes for persistence

Cause: Runtime change via setconcurrentcompactors was not persisted to cassandra.yaml

Terminal window
# To make permanent, update cassandra.yaml
echo "concurrent_compactors: 6" >> /etc/cassandra/cassandra.yaml
# Or edit existing value
sed -i 's/concurrent_compactors:.*/concurrent_compactors: 6/' /etc/cassandra/cassandra.yaml

When viewing concurrent compactors, also check:

Terminal window
# Compaction activity
nodetool compactionstats
# Throughput limit
nodetool getcompactionthroughput
# SSTable counts (indicates if compaction is keeping up)
nodetool tablestats | grep -E "Table:|SSTable count"
# Thread pool stats
nodetool tpstats | grep -i compaction

CommandRelationship
setconcurrentcompactorsModify the setting (includes detailed explanation)
compactionstatsMonitor compaction activity
getcompactionthroughputView I/O limit per compactor
setcompactionthroughputModify I/O limit
tablestatsView SSTable counts
tpstatsView thread pool statistics