cassandra-stress
The official Cassandra benchmarking and load testing tool.
Overview
Section titled “Overview”cassandra-stress is a Java-based tool for:
- Benchmarking cluster performance
- Load testing before production
- Capacity planning
- Regression testing
Basic Commands
Section titled “Basic Commands”Write Test
Section titled “Write Test”# Insert 1 million rowscassandra-stress write n=1000000
# With specific thread countcassandra-stress write n=1000000 -rate threads=50
# With consistency levelcassandra-stress write n=1000000 cl=LOCAL_QUORUM
# Against specific nodescassandra-stress write n=1000000 -node 192.168.1.10,192.168.1.11Read Test
Section titled “Read Test”# Read 1 million rows (requires prior write)cassandra-stress read n=1000000 -rate threads=50
# No warmupcassandra-stress read n=1000000 no-warmupMixed Workload
Section titled “Mixed Workload”# 50% read, 50% writecassandra-stress mixed ratio\(write=1,read=1\) n=1000000
# 70% read, 30% writecassandra-stress mixed ratio\(read=7,write=3\) n=1000000
# Duration-basedcassandra-stress mixed ratio\(read=7,write=3\) duration=10mConnection Options
Section titled “Connection Options”Target Nodes
Section titled “Target Nodes”-node 192.168.1.10-node 192.168.1.10,192.168.1.11,192.168.1.12Authentication
Section titled “Authentication”-mode native cql3 user=cassandra password=cassandraSSL/TLS
Section titled “SSL/TLS”-transport "truststore=/path/truststore.jks truststore-password=pass"
# Full SSL config-transport "truststore=/path/truststore.jks truststore-password=pass keystore=/path/keystore.jks keystore-password=pass"CQL Protocol
Section titled “CQL Protocol”-mode native cql3-port native=9042Rate Limiting
Section titled “Rate Limiting”Thread-Based
Section titled “Thread-Based”# Fixed thread count-rate threads=100
# Thread range (auto-tune)-rate threads>=50 threads<=200Throughput-Based
Section titled “Throughput-Based”# Target ops/sec-rate threads=50 throttle=10000/s
# Fixed rate-rate "fixed=5000/s"Custom Schema
Section titled “Custom Schema”YAML Profile
Section titled “YAML Profile”keyspace: stress_testkeyspace_definition: | CREATE KEYSPACE stress_test WITH replication = { 'class': 'NetworkTopologyStrategy', 'dc1': 3 };
table: userstable_definition: | CREATE TABLE users ( user_id uuid, username text, email text, created_at timestamp, profile_data blob, PRIMARY KEY (user_id) )
columnspec: - name: user_id size: fixed(36) population: uniform(1..10000000) - name: username size: gaussian(5..20) population: uniform(1..10000000) - name: email size: gaussian(15..50) - name: created_at cluster: fixed(1) - name: profile_data size: gaussian(100..1000)
insert: partitions: fixed(1) batchtype: UNLOGGED
queries: read_user: cql: SELECT * FROM users WHERE user_id = ? fields: samerow read_username: cql: SELECT username, email FROM users WHERE user_id = ? fields: samerowRun with Profile
Section titled “Run with Profile”# Insert datacassandra-stress user profile=user_profile.yaml \ ops\(insert=1\) n=1000000
# Mixed operationscassandra-stress user profile=user_profile.yaml \ ops\(insert=1,read_user=3\) duration=30m
# Specific querycassandra-stress user profile=user_profile.yaml \ ops\(read_user=1\) n=500000Column Specifications
Section titled “Column Specifications”Size Distributions
Section titled “Size Distributions”columnspec: # Fixed size - name: id size: fixed(36)
# Gaussian distribution - name: data size: gaussian(100..500) # mean ~300
# Uniform distribution - name: content size: uniform(50..200)
# Exponential distribution - name: blob size: exp(100..10000)Population Distributions
Section titled “Population Distributions”columnspec: - name: user_id population: uniform(1..1000000)
- name: partition_key population: gaussian(1..100000)
# Sequence (incremental) - name: seq_id population: seq(1..10000000)Output and Logging
Section titled “Output and Logging”Log to File
Section titled “Log to File”cassandra-stress write n=1000000 -log file=stress.logGraph Output
Section titled “Graph Output”cassandra-stress write n=1000000 -graph file=results.html title="Write Test"Interval Reporting
Section titled “Interval Reporting”# Report every 5 secondscassandra-stress write n=1000000 -log interval=5Understanding Results
Section titled “Understanding Results”Key Metrics
Section titled “Key Metrics”Results:Op rate : 45,231 op/s # Operations per secondPartition rate: 45,231 pk/s # Partitions per secondRow rate : 45,231 row/s # Rows per secondLatency mean : 4.4 ms # Average latencyLatency median: 2.1 ms # 50th percentileLatency 95th : 12.3 ms # 95th percentileLatency 99th : 35.2 ms # 99th percentileLatency max : 245.1 ms # Maximum observedTotal errors : 0 # Error countPerformance Guidelines
Section titled “Performance Guidelines”| Metric | Good | Warning | Bad |
|---|---|---|---|
| p95 latency | < 20ms | 20-50ms | > 50ms |
| p99 latency | < 50ms | 50-100ms | > 100ms |
| Error rate | 0% | < 0.1% | > 0.1% |
Counter Operations
Section titled “Counter Operations”# Counter writescassandra-stress counter_write n=1000000 -rate threads=50
# Counter readscassandra-stress counter_read n=1000000Advanced Examples
Section titled “Advanced Examples”Warm-Up Then Test
Section titled “Warm-Up Then Test”# Warm-up phasecassandra-stress write n=100000 -rate threads=10
# Actual testcassandra-stress write n=5000000 -rate threads=100Multiple DCs
Section titled “Multiple DCs”cassandra-stress write n=1000000 \ -node dc1-node1,dc1-node2 \ cl=LOCAL_QUORUM \ -rate threads=100Compaction Stress Test
Section titled “Compaction Stress Test”# Heavy writes to trigger compactioncassandra-stress write n=10000000 \ -rate threads=200 \ -schema "replication(strategy=NetworkTopologyStrategy,dc1=3)" \ -log interval=10Time-Series Workload
Section titled “Time-Series Workload”keyspace: metricstable: sensor_datatable_definition: | CREATE TABLE sensor_data ( sensor_id text, bucket text, ts timestamp, value double, PRIMARY KEY ((sensor_id, bucket), ts) ) WITH CLUSTERING ORDER BY (ts DESC)
columnspec: - name: sensor_id size: fixed(10) population: uniform(1..1000) - name: bucket size: fixed(10) - name: ts cluster: uniform(1..1000) - name: value population: gaussian(0..100)Troubleshooting
Section titled “Troubleshooting”Connection Errors
Section titled “Connection Errors”# Verify connectivitycassandra-stress write n=1 -node 192.168.1.10
# Check native transportnodetool statusOut of Memory
Section titled “Out of Memory”# Increase stress tool heapexport JVM_OPTS="-Xms4G -Xmx4G"cassandra-stress write n=10000000Throttling Issues
Section titled “Throttling Issues”# Reduce thread count-rate threads=25
# Add throttle limit-rate threads=50 throttle=5000/sNext Steps
Section titled “Next Steps”- Benchmarking - Benchmarking guide
- Performance - Performance tuning
- Monitoring - Monitor during tests