Skip to content

Instantly share code, notes, and snippets.

@diegopacheco
Last active July 13, 2018 00:15
Show Gist options
  • Select an option

  • Save diegopacheco/a8b3af2154f193614e266adc264dc7e3 to your computer and use it in GitHub Desktop.

Select an option

Save diegopacheco/a8b3af2154f193614e266adc264dc7e3 to your computer and use it in GitHub Desktop.
Perf Trace in Cassandra

Tracing Queries

bin/cqlsh
tracing on
select * from cluster_test.test where key='1';
bin/cqlsh  
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.11.2 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.
cqlsh> tracing on;
Now Tracing is enabled
cqlsh> select * from cluster_test.test where key='1';

 key | value
-----+-------
   1 | works

(1 rows)

Tracing session: 449e8470-854f-11e8-b6f9-87e0f2d93c64

 activity                                                                             | timestamp                  | source    | source_elapsed | client
--------------------------------------------------------------------------------------+----------------------------+-----------+----------------+-----------
                                                                   Execute CQL3 query | 2018-07-11 14:13:33.495000 | 127.0.0.1 |              0 | 127.0.0.1
 Parsing select * from cluster_test.test where key='1'; [Native-Transport-Requests-1] | 2018-07-11 14:13:33.495000 | 127.0.0.1 |            790 | 127.0.0.1
                                    Preparing statement [Native-Transport-Requests-1] | 2018-07-11 14:13:33.496000 | 127.0.0.1 |           1543 | 127.0.0.1
                               Executing single-partition query on test [ReadStage-3] | 2018-07-11 14:13:33.498000 | 127.0.0.1 |           3136 | 127.0.0.1
                                           Acquiring sstable references [ReadStage-3] | 2018-07-11 14:13:33.498000 | 127.0.0.1 |           3398 | 127.0.0.1
                                              Merging memtable contents [ReadStage-3] | 2018-07-11 14:13:33.498000 | 127.0.0.1 |           3615 | 127.0.0.1
                                            Key cache hit for sstable 2 [ReadStage-3] | 2018-07-11 14:13:33.499000 | 127.0.0.1 |           4010 | 127.0.0.1
                                 Read 1 live rows and 0 tombstone cells [ReadStage-3] | 2018-07-11 14:13:33.500000 | 127.0.0.1 |           4975 | 127.0.0.1
                                                                     Request complete | 2018-07-11 14:13:33.500587 | 127.0.0.1 |           5587 | 127.0.0.1


cqlsh> 

Load and Latency

nodetool tpstats

Table Latency

bin/nodetool tablehistograms cluster_test.test
bin/nodetool tablehistograms cluster_test.test

cluster_test/test histograms
Percentile  SSTables     Write Latency      Read Latency    Partition Size        Cell Count
                              (micros)          (micros)           (bytes)                  
50%             1.00              0.00           1955.67                29                 1
75%             1.00              0.00           1955.67                29                 1
95%             1.00              0.00           1955.67                29                 1
98%             1.00              0.00           1955.67                29                 1
99%             1.00              0.00           1955.67                29                 1
Min             1.00              0.00           1629.72                25                 0
Max             1.00              0.00           1955.67                29                 1

Check cache Hits

bin/nodetool info

Increase Row Cache

ALTER TABLE cluster_test.test WITH caching = {'keys': 'ALL', 'rows_per_partition': '1000'};

Repair the Table

bin/nodetool repair

Check for Compactions / Trigger it

bin/nodetool compact cluster_test
bin/nodetool compactionstats

Change Compaction

ALTER TABLE cluster_test.test WITH compaction = {'class': 'LeveledCompactionStrategy' };

Change Bloom Filters

ALTER TABLE cluster_test.test WITH bloom_filter_fp_chance = 0.5;
bin/nodetool compact cluster_test