Testing performance impact using tracing
Tracing records all activity related to a request. These steps use tracing to show queries on a keyspace with a replication factor of 3 using different consistency levels (CL):
-
ONE processes responses from one of three replicas
-
QUORUM from two of three replicas
-
ALL from three of three replicas
-
On the cqlsh command line, create a keyspace that specifies using three replicas for data distribution in the cluster.
CREATE KEYSPACE IF NOT EXISTS cycling_alt WITH REPLICATION = { 'class': 'SimpleStrategy', 'replication_factor': 3 };
-
Create a table and insert a row.
USE cycling_alt; CREATE TABLE IF NOT EXISTS cycling_alt.cyclist_name ( id int PRIMARY KEY, lastname text, firstname text );
-
Turn on tracing and use the CONSISTENCY command to ensure the consistency level is ONE, the default.
TRACING ON; CONSISTENCY;
The output is:
Current consistency level is ONE.
-
Query the table to read the row.
SELECT * FROM cycling_alt.cyclist_name WHERE id = 1;
-
id | firstname | lastname
----+-----------+----------
1 | Melissa | HOSKINS
(1 rows)
+
The tracing results list all the actions taken to complete the SELECT
statement.
-
Change the consistency level to QUORUM to trace what happens during a read with a QUORUM consistency level.
CONSISTENCY QUORUM; SELECT * FROM cycling_alt.cyclist_name WHERE id = 1;
Consistency level set to QUORUM.
-
Change the consistency level to ALL and run the SELECT statement again.
CONSISTENCY ALL; SELECT * FROM cycling_alt.cyclist_name WHERE id = 1;
Consistency level set to ALL.