The cassandra-stress tool

The cassandra-stress tool is a Java-based stress testing utility for basic benchmarking and load testing a Cassandra cluster.

Use cassandra-stress to:

  • Quickly determine how a schema performs.
  • Understand how your database scales.
  • Optimize your data model and settings.
  • Determine production capacity.

The cassandra-stress tool also supports a YAML-based profile for defining specific schemas with various compaction strategies, cache settings, and types. Sample files are located in:

  • Cassandra package installations: /usr/share/docs/cassandra/examples
  • Cassandra tarball installations: install_location/tools/

Simple read and write examples

Insert (write) ten million rows

cassandra-stress write n=10000000 -rate threads=500 -node 206.189.128.248,159.89.164.94,159.89.167.98,139.59.30.118,159.65.144.109,159.65.159.5

Connected to cluster: MyCassandraCluster, max pending requests per connection 128, max connections per host 8
Datatacenter: dc2; Host: /139.59.30.118; Rack: rack1
Datatacenter: dc2; Host: /159.65.159.5; Rack: rack1
Datatacenter: dc1; Host: /206.189.128.248; Rack: rack1
Datatacenter: dc1; Host: /159.89.164.94; Rack: rack1
Datatacenter: dc1; Host: /159.89.167.98; Rack: rack1
Datatacenter: dc2; Host: /159.65.144.109; Rack: rack1
Created keyspaces. Sleeping 6s for propagation.
Sleeping 2s...
Warming up WRITE with 300000 iterations...
Failed to connect over JMX; not collecting these stats
com.datastax.driver.core.exceptions.UnavailableException: Not enough replicas available for query at consistency LOCAL_ONE (1 required but only 0 alive)
cqlsh

cqlsh> ALTER KEYSPACE keyspace1 WITH replication = {'class' : 'NetworkTopologyStrategy', 'dc1' : 2, 'dc2' : 2};
cassandra-stress write n=10000000 -rate threads=500 -node 206.189.128.248,159.89.164.94,159.89.167.98,139.59.30.118,159.65.144.109,159.65.159.5

Running with 4 threadCount
Running WRITE with 4 threads for 10000000 iteration
Failed to connect over JMX; not collecting these stats
type       total ops,    op/s,    pk/s,   row/s,    mean,     med,     .95,     .99,    .999,     max,   time,   stderr, errors,  gc: #,  max ms,  sum ms,  sdv ms,      mb
total,          6270,    6270,    6270,    6270,     0.6,     0.4,     0.8,     3.7,    44.5,    56.1,    1.0,  0.00000,      0,      0,       0,       0,       0,       0
total,         14349,    8079,    8079,    8079,     0.5,     0.4,     0.7,     1.3,    16.2,    48.3,    2.0,  0.08627,      0,      0,       0,       0,       0,       0
total,         23628,    9279,    9279,    9279,     0.4,     0.4,     0.7,     0.9,     2.0,     4.8,    3.0,  0.07934,      0,      0,       0,       0,       0,       0
...
...
...
total,       9948126,   29696,   29696,   29696,    17.0,     9.7,    62.7,   170.8,   191.1,   197.3,  240.0,  0.00551,      0,      0,       0,       0,       0,       0
total,       9985436,   37310,   37310,   37310,    13.5,     9.5,    40.0,    75.0,   107.0,   135.7,  241.0,  0.00550,      0,      0,       0,       0,       0,       0
total,      10000000,   40366,   40366,   40366,    12.4,     7.6,    38.2,    70.3,   121.1,   139.5,  241.4,  0.00571,      0,      0,       0,       0,       0,       0


Results:
Op rate                   :   41,432 op/s  [WRITE: 41,432 op/s]
Partition rate            :   41,432 pk/s  [WRITE: 41,432 pk/s]
Row rate                  :   41,432 row/s [WRITE: 41,432 row/s]
Latency mean              :   12.0 ms [WRITE: 12.0 ms]
Latency median            :    8.6 ms [WRITE: 8.6 ms]
Latency 95th percentile   :   35.5 ms [WRITE: 35.5 ms]
Latency 99th percentile   :   69.3 ms [WRITE: 69.3 ms]
Latency 99.9th percentile :  109.6 ms [WRITE: 109.6 ms]
Latency max               :  376.7 ms [WRITE: 376.7 ms]
Total partitions          : 10,000,000 [WRITE: 10,000,000]
Total errors              :          0 [WRITE: 0]
Total GC count            : 0
Total GC memory           : 0.000 KiB
Total GC time             :    0.0 seconds
Avg GC time               :    NaN ms
StdDev GC time            :    0.0 ms
Total operation time      : 00:04:01

END
cqlsh

cqlsh> use keyspace1;
cqlsh:keyspace1> DESCRIBE table standard1;

CREATE TABLE keyspace1.standard1 (
    key blob PRIMARY KEY,
    "C0" blob,
    "C1" blob,
    "C2" blob,
    "C3" blob,
    "C4" blob
) WITH COMPACT STORAGE
    AND bloom_filter_fp_chance = 0.01
    AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
    AND comment = ''
    AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
    AND compression = {'enabled': 'false'}
    AND crc_check_chance = 1.0
    AND dclocal_read_repair_chance = 0.1
    AND default_time_to_live = 0
    AND gc_grace_seconds = 864000
    AND max_index_interval = 2048
    AND memtable_flush_period_in_ms = 0
    AND min_index_interval = 128
    AND read_repair_chance = 0.0
    AND speculative_retry = '99PERCENTILE';

cqlsh:keyspace1> SELECT COUNT(*) FROM standard1;

 count
---------
 1000000

(1 rows)

Warnings :
Aggregation query used without partition key

Read ten million rows

cassandra-stress read n=10000000 -rate threads=500 -node 206.189.128.248,159.89.164.94,159.89.167.98,139.59.30.118,159.65.144.109,159.65.159.5

Sleeping 2s...
Warming up READ with 300000 iterations...
Connected to cluster: MyCassandraCluster, max pending requests per connection 128, max connections per host 8
Datatacenter: dc2; Host: /139.59.30.118; Rack: rack1
Datatacenter: dc2; Host: /159.65.159.5; Rack: rack1
Datatacenter: dc1; Host: /206.189.128.248; Rack: rack1
Datatacenter: dc1; Host: /159.89.164.94; Rack: rack1
Datatacenter: dc1; Host: /159.89.167.98; Rack: rack1
Datatacenter: dc2; Host: /159.65.144.109; Rack: rack1
Failed to connect over JMX; not collecting these stats
Running READ with 500 threads for 10000000 iteration
Failed to connect over JMX; not collecting these stats
type       total ops,    op/s,    pk/s,   row/s,    mean,     med,     .95,     .99,    .999,     max,   time,   stderr, errors,  gc: #,  max ms,  sum ms,  sdv ms,      mb
total,         44497,   44497,   44497,   44497,     6.4,     4.1,    18.5,    39.0,   127.5,   154.3,    1.0,  0.00000,      0,      0,       0,       0,       0,       0
total,        109769,   65272,   65272,   65272,     7.7,     4.7,    21.4,    41.0,   144.0,   164.9,    2.0,  0.13813,      0,      0,       0,       0,       0,       0
total,        190948,   81179,   81179,   81179,     6.2,     3.7,    19.1,    42.5,    71.8,   118.9,    3.0,  0.12716,      0,      0,       0,       0,       0,       0
...
...
...
total,       9870019,   74515,   74515,   74515,     6.7,     4.8,    18.7,    46.4,    69.9,    90.6,  119.0,  0.00549,      0,      0,       0,       0,       0,       0
total,       9950523,   80504,   80504,   80504,     6.1,     4.2,    18.5,    38.0,    63.9,    73.2,  120.0,  0.00545,      0,      0,       0,       0,       0,       0
total,      10000000,   68430,   68430,   68430,     7.3,     5.5,    19.7,    45.8,    71.4,    81.9,  120.7,  0.00554,      0,      0,       0,       0,       0,       0


Results:
Op rate                   :   82,834 op/s  [READ: 82,834 op/s]
Partition rate            :   82,834 pk/s  [READ: 82,834 pk/s]
Row rate                  :   82,834 row/s [READ: 82,834 row/s]
Latency mean              :    6.0 ms [READ: 6.0 ms]
Latency median            :    4.1 ms [READ: 4.1 ms]
Latency 95th percentile   :   18.1 ms [READ: 18.1 ms]
Latency 99th percentile   :   36.0 ms [READ: 36.0 ms]
Latency 99.9th percentile :   61.0 ms [READ: 61.0 ms]
Latency max               :  172.1 ms [READ: 172.1 ms]
Total partitions          : 10,000,000 [READ: 10,000,000]
Total errors              :          0 [READ: 0]
Total GC count            : 0
Total GC memory           : 0.000 KiB
Total GC time             :    0.0 seconds
Avg GC time               :    NaN ms
StdDev GC time            :    0.0 ms
Total operation time      : 00:02:00

END

results matching ""

    No results matching ""