Database Reference
In-Depth Information
Row cache
Row cache is true caching. It caches a complete row of data and returns immediately
without touching the hard drive. It is fast and complete. Row cache stores data off-heap (if
JNA is available), which means that it will be unaffected by the garbage collector.
Cassandra is capable of storing really large rows of data with about 2 billion columns in it.
This means that the cache is going to take up much space, which may not be what you
wanted. While row cache is generally good to boost the read speed, it is best suited for
not-so-large rows. However, you can cache the users table in row cache, but it will be a
bad idea to have the users_browsing_history or users_click_pattern
table, in a row cache.
Key cache
Key cache is to store the row keys in memory. Key caches are default for a table. It does
not take much space, but it boosts performance to a large extent (but less than the row
cache). As of Cassandra Version 2.1.0, the key cache is assigned to 100 MB or 5 percent
of the JVM heap memory, whichever is low.
Key caches contain information about the location of the row in SSTables, so it's just one
disk seek to retrieve the data. This short-circuits the process of looking through the
sampled index and then scanning the index file for the key range. Since it does not take
large space as row cache, one can have large number of keys cached in relatively small
memory.
Cache settings
The general rule of thumb is, for all normal purposes, key cache is good enough. You can
tweak key cache to stretch its limits. You'd get a lot of performance gain for just a little in-
crease in key cache size in key cache settings. Row caching, on the other hand, needs a
little thinking to do. A good fit data for row cache is the same as a good fit data for a
third-party caching mechanism. The data should be read mostly, and mutated occasionally.
Rows with smaller number of columns are better suited. Before you go ahead with cache
tweaking, you may want to check the current cache usage. You can use JConsole to see
cache hit. We will learn more about JConsole in Chapter 7 , Monitoring . In JConsole, the
cache statistics can be obtained by expanding the org.apache.cassandra.db
menu. It shows cache hit rate and the number of hits and cache size for a particular node
and table.
Search WWH ::




Custom Search