Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Cassandra Row caching and Partition key caching

Tags:

cassandra

What is the difference between row cache and Partition key cache? shall i need to use both for the good performance Perspective.

I have already read the basic definition from dataStax website

The partition key cache is a cache of the partition index for a Cassandra table. Using the key cache instead of relying on the OS page cache saves CPU time and memory. However, enabling just the key cache results in disk (or OS page cache) activity to actually read the requested data rows.

The row cache is similar to a traditional cache like memcached. When a row is accessed, the entire row is pulled into memory, merging from multiple SSTables if necessary, and cached, so that further reads against that row can be satisfied without hitting disk at all.

Can anyone elaborate the area of uses . do need to have both implement both . ?

like image 922
Sarkar Avatar asked Aug 01 '14 11:08

Sarkar


Video Answer


1 Answers

TL;DR : You want to use Key Cache and most likely do NOT want row cache.

Key cache helps C* know where a particular partition begins in the SStables. This means that C* does not have to read anything to determine the right place to seek to in the file to begin reading the row. This is good for almost all use cases because it speeds up reads considerably by potentially removing the need for an IOP in the read-path.

Row Cache has a much more limited use case. Row cache pulls entire partitions into memory. If any part of that partition has been modified, the entire cache for that row is invalidated. For large partitions this means the cache can be frequently caching and invalidating big pieces of memory. Because you really need mostly static partitions for this to be useful, for most use cases it is recommended that you do not use Row Cache.

like image 167
RussS Avatar answered Oct 23 '22 12:10

RussS