Building and running step 6

Row caches and query paging help improve the performance of Cassandra when running queries that return large result sets.

Optimize the performance of the queries in Playlist by enabling row caching and using paging in the queries that return large data sets.

The location of the cassandra.yaml file depends on the type of installation:
Package installations /etc/cassandra/cassandra.yaml
Tarball installations install_location/resources/cassandra/conf/cassandra.yaml

Prerequisites

You must have set up your environment before starting this step.

Procedure

  1. In a terminal, go to the playlist workspace.
    cd playlist
  2. Check out the step6 branch using git.
    git checkout step6
  3. Run the cqlsh command.
    cqlsh
  4. In the playlist keyspace alter the tracks_by_genre and tracks_by_artist tables to cache the first 100 rows in the partition.
    use playlist;
    ALTER TABLE track_by_genre WITH caching = {'rows_per_partition':'100'};
    ALTER TABLE track_by_artist WITH caching = {'rows_per_partition':'100'};
    
    
  5. Quit cqlsh.
    exit;
  6. Using a text editor, modify the row_cache_size_in_mb option in cassandra.yaml to enable the row cache and set the amount of memory in the row cache to 50 MB.
    # Default value is 0, to disable row caching.
    row_cache_size_in_mb: 50
  7. Restart DataStax Enterprise.

    For package installs on Debian or Ubuntu:

    sudo service dse restart

    For tarball installs, see the topics on stopping and starting nodes.

  8. Build and run Playlist using mvn.
    mvn verify cargo:run
  9. In a web browser, navigate to http://localhost:8080/playlist.

    Navigate through the artist or genre catalog several times. This will add the table rows to the row cache.

  10. In a separate terminal use the nodetool info command to see the row cache entries and size.
    nodetool info
    Row Cache: entries 3, size 84.82 KB, capacity 50 MB, 4 hits, 7 requests, 0.571 recent hit rate, 0 save period in seconds

    Each time you click on a genre or artist the cache size will increase.