nodetool getconcurrentcompactors
Displays the number of concurrent compactor threads.
Synopsis
Section titled “Synopsis”nodetool [connection_options] getconcurrentcompactorsSee connection options for connection options.
Description
Section titled “Description”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.
Examples
Section titled “Examples”Basic Usage
Section titled “Basic Usage”nodetool getconcurrentcompactorsSample output:
Current concurrent compactors: 4Check Cluster-Wide Consistency
Section titled “Check Cluster-Wide Consistency”#!/bin/bashecho "=== Concurrent Compactors Across Cluster ==="
# Get list of node IPs from local nodetool statusnodes=$(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"doneSample output:
=== Concurrent Compactors Across Cluster ===192.168.1.101: 4 compactors192.168.1.102: 4 compactors192.168.1.103: 4 compactorsUnderstanding the Value
Section titled “Understanding the Value”Default Calculation
Section titled “Default Calculation”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.
| Hardware | Expected Default |
|---|---|
| 8 cores, 1 disk | 2 (minimum) |
| 8 cores, 4 disks | 4 |
| 16 cores, 8 disks | 8 (maximum) |
| 4 cores, 8 disks | 4 |
| 1 core, 1 disk | 2 (minimum) |
Interpreting Different Values
Section titled “Interpreting Different Values”| Value | Indicates | Typical Reason |
|---|---|---|
| 1 | Minimal parallelism | Single disk or resource-constrained |
| 2-4 | Moderate parallelism | Balanced configuration |
| 5-8 | High parallelism | Multiple disks, write-heavy workload |
| 8+ | Maximum parallelism | Large JBOD, bulk loading |
When to Check This Value
Section titled “When to Check This Value”Performance Investigation
Section titled “Performance Investigation”When compaction appears slow:
# Check compactor countnodetool getconcurrentcompactors
# Compare with pending tasksnodetool compactionstats | head -10
# If many pending tasks and few compactors, consider increasingCapacity Planning
Section titled “Capacity Planning”Before changing workload:
# Current compactorsnodetool getconcurrentcompactors
# Current hardware capacityecho "CPU cores: $(nproc)"echo "Data directories: $(grep -A 10 'data_file_directories:' /etc/cassandra/cassandra.yaml | grep '^ *-' | wc -l)"
# Current compaction throughputnodetool getcompactionthroughputConfiguration Audit
Section titled “Configuration Audit”Verify cluster consistency:
#!/bin/bashecho "Auditing compactor settings..."
# Check runtime valuesecho ""echo "Runtime values:"# Get list of node IPs from local nodetool statusfor 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)"Relationship to Performance
Section titled “Relationship to Performance”Impact on Compaction Throughput
Section titled “Impact on Compaction Throughput”Total Compaction Capacity ≈ concurrent_compactors × compaction_throughput_mb_per_sec| Compactors | Throughput Setting | Total Capacity |
|---|---|---|
| 2 | 64 MB/s | ~128 MB/s |
| 4 | 64 MB/s | ~256 MB/s |
| 8 | 64 MB/s | ~512 MB/s |
Checking If Current Value Is Adequate
Section titled “Checking If Current Value Is Adequate”#!/bin/bashecho "=== Compaction Health Check ==="
# Current settingcompactors=$(nodetool getconcurrentcompactors | grep -oP '\d+')echo "Concurrent compactors: $compactors"
# Pending taskspending=$(nodetool compactionstats | grep "pending tasks" | grep -oP '\d+')echo "Pending compaction tasks: $pending"
# Assessmentif [ "$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"fiConfiguration Reference
Section titled “Configuration Reference”Runtime vs cassandra.yaml
Section titled “Runtime vs cassandra.yaml”| Source | What getconcurrentcompactors Shows |
|---|---|
| After startup (no changes) | Value from cassandra.yaml or calculated default |
After setconcurrentcompactors | Runtime-modified value |
| After restart | Value from cassandra.yaml (runtime changes lost) |
Checking Both Values
Section titled “Checking Both Values”# Runtime (active) valuenodetool getconcurrentcompactors
# Configured (persistent) valuegrep concurrent_compactors /etc/cassandra/cassandra.yamlIf these differ, someone used setconcurrentcompactors to change the runtime value.
cassandra.yaml Reference
Section titled “cassandra.yaml Reference”# Number of simultaneous compactions to allow# Comment out or omit for auto-calculated defaultconcurrent_compactors: 4Common Scenarios
Section titled “Common Scenarios”Value Lower Than Expected
Section titled “Value Lower Than Expected”Possible causes:
- Explicitly set low in cassandra.yaml
- Single data directory configured
- Few CPU cores
# Check why value is lowecho "CPU cores: $(nproc)"grep data_file_directories -A 5 /etc/cassandra/cassandra.yamlgrep concurrent_compactors /etc/cassandra/cassandra.yamlValue Differs Across Nodes
Section titled “Value Differs Across Nodes”Possible causes:
- Different hardware configurations
- Manual runtime changes not persisted
- Inconsistent cassandra.yaml
# Standardize across clusterTARGET=4# Get list of node IPs from local nodetool statusfor node in $(nodetool status | grep "^UN" | awk '{print $2}'); do ssh "$node" "nodetool setconcurrentcompactors $TARGET"done
# Update cassandra.yaml on all nodes for persistenceValue Changed After Restart
Section titled “Value Changed After Restart”Cause: Runtime change via setconcurrentcompactors was not persisted to cassandra.yaml
# To make permanent, update cassandra.yamlecho "concurrent_compactors: 6" >> /etc/cassandra/cassandra.yaml
# Or edit existing valuesed -i 's/concurrent_compactors:.*/concurrent_compactors: 6/' /etc/cassandra/cassandra.yamlRelated Metrics
Section titled “Related Metrics”When viewing concurrent compactors, also check:
# Compaction activitynodetool compactionstats
# Throughput limitnodetool getcompactionthroughput
# SSTable counts (indicates if compaction is keeping up)nodetool tablestats | grep -E "Table:|SSTable count"
# Thread pool statsnodetool tpstats | grep -i compactionRelated Commands
Section titled “Related Commands”| Command | Relationship |
|---|---|
| setconcurrentcompactors | Modify the setting (includes detailed explanation) |
| compactionstats | Monitor compaction activity |
| getcompactionthroughput | View I/O limit per compactor |
| setcompactionthroughput | Modify I/O limit |
| tablestats | View SSTable counts |
| tpstats | View thread pool statistics |