Database Reference
In-Depth Information
Caching
There are several settings related to caching, both within Cassandra and at the operating system
level. Caches can use considerable memory, and it's a good idea to tune them carefully once you
understand your usage patterns.
There are two primary caches built into Cassandra: a row cache and a key cache. The row cache
caches complete rows (all of their columns), so it is a superset of the key cache. If you are using
a row cache for a given column family, you will not need to use a key cache on it as well.
Your caching strategy should therefore be tuned in accordance with a few factors:
▪ Consider your queries, and use the cache type that best fits your queries.
▪ Consider the ratio of your heap size to your cache size, and do not allow the cache to over-
whelm your heap.
▪ Consider the size of your rows against the size of your keys. Typically keys will be much
smaller than entire rows.
The keys_cached setting indicates the number of key locations—not key values—that will be
saved in memory. This can be specified as a fractional value (a number between 0 and 1) or as
an integer. If you use a fraction, you're indicating a percentage of keys to cache, and an integer
value indicates an absolute number of keys whose locations will be cached.
NOTE
The keys_cached setting is a per-column family setting, so different column families can have different
numbers of key locations cached if some are used more frequently than others.
This setting will consume considerable memory, but can be a good trade-off if your locations are
not hot already.
The purpose of disk_access_mode is to enable memory mapped files so that the operating sys-
tem can cache reads, thus reducing the load on Cassandra's internal caches. This sounds great,
but in practice, disk_access_mode is one of the less-useful settings, and at this point doesn't
work exactly as was originally envisioned. This may be improved in the future, but it is just as
likely that the setting will be removed. Certainly feel free to play around with it, but you might
not see much difference.
You can also populate the row cache when the server starts up. To do this, use the pre-
load_row_cache element. The default setting for this is false, but you will want to set it to true
Search WWH ::




Custom Search