nodetool toppartitions
Samples and displays the most active partitions.
Relationship to profileload
Since Cassandra 4.0, toppartitions is a wrapper around profileload (TopPartitions extends ProfileLoad). Both commands remain available and accept the same options. The profileload command offers the same functionality with a broader profiling scope.
Synopsis
Section titled “Synopsis”nodetool [connection_options] toppartitions [options] [keyspace] [table] [duration]See connection options for connection options.
Description
Section titled “Description”nodetool toppartitions samples partition access over a specified duration and reports the most frequently accessed partitions. This helps identify hot partitions that may be causing performance issues.
Since Cassandra 4.0, this command is a wrapper around profileload (source).
Arguments
Section titled “Arguments”All arguments are optional. When omitted, defaults are used.
| Argument | Description | Default |
|---|---|---|
keyspace | The keyspace to sample | All keyspaces |
table | The table to sample | All tables |
duration | Sampling duration in milliseconds | 10000 (10 seconds) |
Options
Section titled “Options”| Option | Description |
|---|---|
-s, --capacity <count> | Capacity of the sampler reservoir (default: 256) |
-k, --top-count <count> | Number of top partitions to return (default: 10) |
-a, --samplers <samplers> | Comma-separated sampler types: READS, WRITES, CAS_CONTENTIONS, LOCAL_READ_TIME, WRITE_SIZE (default: all) |
-i, --interval <ms> | Sampling interval in milliseconds |
-t, --stop | Stop ongoing sampling |
-l, --list | List active sampling sessions |
Output Format
Section titled “Output Format”WRITES Sampler: Cardinality: ~1000 Top 10 partitions: Partition Count +/- user_12345 150 10 user_67890 120 8 user_11111 95 7 ...
READS Sampler: Cardinality: ~800 Top 10 partitions: Partition Count +/- product_abc 200 15 product_xyz 180 12 ...Examples
Section titled “Examples”Sample for 10 Seconds (10000 ms)
Section titled “Sample for 10 Seconds (10000 ms)”nodetool toppartitions my_keyspace my_table 10000Sample with More Results
Section titled “Sample with More Results”nodetool toppartitions -k 20 my_keyspace my_table 30000Sample Reads Only
Section titled “Sample Reads Only”nodetool toppartitions -a READS my_keyspace my_table 10000Sample Writes Only
Section titled “Sample Writes Only”nodetool toppartitions -a WRITES my_keyspace my_table 10000Sample CAS Contentions
Section titled “Sample CAS Contentions”nodetool toppartitions -a CAS_CONTENTIONS my_keyspace my_table 10000List Active Sampling Sessions
Section titled “List Active Sampling Sessions”nodetool toppartitions -lStop Ongoing Sampling
Section titled “Stop Ongoing Sampling”nodetool toppartitions -tUnderstanding Results
Section titled “Understanding Results”Cardinality
Section titled “Cardinality”Cardinality: ~1000Estimated number of unique partitions accessed during sampling.
user_12345 150 10150: Number of times this partition was accessed10: Statistical margin of error
Hot Partition Indicators
Section titled “Hot Partition Indicators”| Metric | Warning Sign |
|---|---|
| Single partition >> others | Potential hot partition |
| High count + high error | Variable access pattern |
| Low cardinality + high count | Few partitions handling all traffic |
Use Cases
Section titled “Use Cases”Identify Hot Partitions
Section titled “Identify Hot Partitions”# Sample during peak trafficnodetool toppartitions my_keyspace my_table 60000Hot partitions may indicate:
- Data model issues (poor partition key choice)
- Application bugs (always accessing same key)
- Natural access patterns (celebrity problem)
Performance Troubleshooting
Section titled “Performance Troubleshooting”# When seeing high latencynodetool toppartitions -s 20 my_keyspace slow_table 30000If one partition dominates, investigate that partition.
Capacity Planning
Section titled “Capacity Planning”# Understand access distributionnodetool toppartitions -s 50 my_keyspace my_table 300000Even distribution = good Skewed distribution = potential scaling issue
Sampling Strategies
Section titled “Sampling Strategies”Short Sample (Quick Check)
Section titled “Short Sample (Quick Check)”# 10 second samplenodetool toppartitions my_keyspace my_table 10000Good for: Quick identification of obvious hot spots
Medium Sample (Typical Analysis)
Section titled “Medium Sample (Typical Analysis)”# 1 minute samplenodetool toppartitions my_keyspace my_table 60000Good for: Normal troubleshooting
Long Sample (Thorough Analysis)
Section titled “Long Sample (Thorough Analysis)”# 5 minute samplenodetool toppartitions my_keyspace my_table 300000Good for: Capturing intermittent patterns
Show Top 50 Partitions
Section titled “Show Top 50 Partitions”nodetool toppartitions -k 50 my_keyspace my_table 300000Interpreting Access Patterns
Section titled “Interpreting Access Patterns”Healthy Distribution
Section titled “Healthy Distribution”Partition Countpart_1 100part_2 95part_3 92part_4 88...Traffic distributed relatively evenly.
Hot Partition
Section titled “Hot Partition”Partition Counthot_key 5000part_2 50part_3 45...One partition receiving 100x more traffic than others.
Write-Heavy Partition
Section titled “Write-Heavy Partition”WRITES: hot_key 1000 other 10
READS: hot_key 50 other 45Partition is write-heavy—may need data model review.
Addressing Hot Partitions
Section titled “Addressing Hot Partitions”Data Model Solutions
Section titled “Data Model Solutions”-
Add randomization to partition key
-- Instead ofCREATE TABLE events (date DATE, event_id UUID, ...);-- Use bucketingCREATE TABLE events (date DATE, bucket INT, event_id UUID, ...); -
Composite partition key
PRIMARY KEY ((user_id, bucket), timestamp)
Application Solutions
Section titled “Application Solutions”- Client-side caching - Reduce read frequency
- Write batching - Reduce write frequency
- Load spreading - Distribute across multiple keys
Automation Example
Section titled “Automation Example”#!/bin/bashKEYSPACE=$1TABLE=$2DURATION=60000 # 1 minuteTHRESHOLD=100 # Alert if count > 100
result=$(nodetool toppartitions -k 5 $KEYSPACE $TABLE $DURATION 2>/dev/null)
# Parse top partition counttop_count=$(echo "$result" | grep -A2 "Top" | tail -1 | awk '{print $2}')
if [ -n "$top_count" ] && [ "$top_count" -gt "$THRESHOLD" ]; then echo "ALERT: Hot partition detected in $KEYSPACE.$TABLE" echo "$result"fiLimitations
Section titled “Limitations”Sampling Limitations
- Results are statistical samples, not exact counts
- Short samples may miss intermittent patterns
- High-traffic tables need longer sampling
- Sampling adds minimal overhead
Related Commands
Section titled “Related Commands”| Command | Relationship |
|---|---|
| profileload | Primary command (toppartitions is an alias) |
| tablestats | Overall table statistics |
| tablehistograms | Latency distributions |
| proxyhistograms | Coordinator latencies |
| tpstats | Thread pool statistics |