Cassandra Performance Benchmarking
Measure and validate Cassandra cluster performance.
cassandra-stress
Section titled “cassandra-stress”The official benchmarking tool included with Cassandra.
Basic Usage
Section titled “Basic Usage”# Write test (1M operations)cassandra-stress write n=1000000 -rate threads=50
# Read testcassandra-stress read n=1000000 -rate threads=50
# Mixed workload (50% read, 50% write)cassandra-stress mixed ratio\(write=1,read=1\) n=1000000 -rate threads=50Connection Options
Section titled “Connection Options”cassandra-stress write n=1000000 \ -node 192.168.1.10,192.168.1.11,192.168.1.12 \ -rate threads=100 \ -mode native cql3 \ -transport "truststore=/path/to/truststore.jks truststore-password=pass" \ -log file=results.logCustom Schema
Section titled “Custom Schema”# Create YAML profilecat > user_profile.yaml << 'EOF'keyspace: test_kskeyspace_definition: | CREATE KEYSPACE test_ks WITH replication = {'class': 'NetworkTopologyStrategy', 'dc1': 3};
table: userstable_definition: | CREATE TABLE users ( user_id uuid PRIMARY KEY, name text, email text, created_at timestamp )
columnspec: - name: user_id size: fixed(36) - name: name size: gaussian(10..50) - name: email size: gaussian(20..50) - name: created_at
insert: partitions: fixed(1) batchtype: UNLOGGED
queries: read_by_id: cql: SELECT * FROM users WHERE user_id = ? fields: samerowEOF
# Run with profilecassandra-stress user profile=user_profile.yaml ops\(insert=3,read_by_id=7\) n=1000000Key Metrics to Measure
Section titled “Key Metrics to Measure”Throughput
Section titled “Throughput”Op rate : Operations per secondPartition rate: Partitions written/read per secondRow rate : Rows affected per secondLatency
Section titled “Latency”Latency mean : Average latencyLatency median: 50th percentileLatency 95th : 95th percentile (target < 50ms)Latency 99th : 99th percentileLatency max : Maximum observed latencyBenchmark Scenarios
Section titled “Benchmark Scenarios”Write Performance
Section titled “Write Performance”# Sequential writescassandra-stress write n=5000000 cl=LOCAL_QUORUM \ -rate threads=200 \ -node node1,node2,node3
# Expected: 20,000-100,000 ops/sec per node (varies by hardware)Read Performance
Section titled “Read Performance”# Random readscassandra-stress read n=5000000 cl=LOCAL_QUORUM \ -rate threads=200 \ -node node1,node2,node3
# Expected: 10,000-50,000 ops/sec per nodeMixed Workload
Section titled “Mixed Workload”# 70% read, 30% write (typical application)cassandra-stress mixed ratio\(read=7,write=3\) n=5000000 cl=LOCAL_QUORUM \ -rate threads=200Counter Workload
Section titled “Counter Workload”cassandra-stress counter_write n=1000000 \ -rate threads=50YCSB (Yahoo Cloud Serving Benchmark)
Section titled “YCSB (Yahoo Cloud Serving Benchmark)”Alternative benchmark suite for database comparison.
Set up
Section titled “Set up”# Clone YCSBgit clone https://github.com/brianfrankcooper/YCSB.gitcd YCSB
# Build Cassandra bindingmvn -pl site.ycsb:cassandra-binding -am clean packageRun Workloads
Section titled “Run Workloads”# Load data./bin/ycsb load cassandra-cql -s -P workloads/workloada \ -p hosts="node1,node2,node3" \ -p recordcount=1000000
# Run workload A (50% read, 50% update)./bin/ycsb run cassandra-cql -s -P workloads/workloada \ -p hosts="node1,node2,node3" \ -p operationcount=1000000YCSB Workloads
Section titled “YCSB Workloads”| Workload | Read | Update | Insert | Scan | RMW |
|---|---|---|---|---|---|
| A | 50% | 50% | - | - | - |
| B | 95% | 5% | - | - | - |
| C | 100% | - | - | - | - |
| D | 95% | - | 5% | - | - |
| E | - | - | 5% | 95% | - |
| F | 50% | - | - | - | 50% |
Interpreting Results
Section titled “Interpreting Results”Good Performance Indicators
Section titled “Good Performance Indicators”✓ Op rate consistent across nodes✓ p99 latency < 100ms✓ No timeouts or errors✓ Stable throughput over time✓ GC pauses < 200msProblem Indicators
Section titled “Problem Indicators”✗ High latency variance✗ Increasing latency over time✗ Error rate > 0.1%✗ Uneven distribution across nodes✗ GC pauses > 500msBenchmark Best Practices
Section titled “Benchmark Best Practices”- Warm up cluster - Run shorter test first
- Use realistic data - Match production data patterns
- Test at scale - Use production-like data volumes
- Run multiple times - Average results across runs
- Monitor during tests - Watch GC, I/O, CPU
- Test failure scenarios - One node down, network partition
Sample Results Interpretation
Section titled “Sample Results Interpretation”Results:Op rate : 45,231 op/sPartition rate : 45,231 pk/sRow rate : 45,231 row/sLatency mean : 4.4 msLatency median : 2.1 msLatency 95th percentile : 12.3 msLatency 99th percentile : 35.2 msLatency 99.9th percentile : 89.4 msLatency max : 245.1 msTotal partitions : 5,000,000Total errors : 0Analysis:
- 45K ops/sec is good for 3-node cluster
- Median 2.1ms is excellent
- p99 at 35ms is acceptable
- No errors indicates stability
Next Steps
Section titled “Next Steps”- cassandra-stress - Full tool reference
- Query Optimization - Optimize slow queries
- Key Metrics - Production monitoring