Every Solr cache trades heap for speed. Sized against your own document count, they help; copied from an example, they can take the heap.
Solr caches are worth having, and they are also the easiest way to lose a heap. Four of them are configurable in solrconfig.xml, and each entry they hold is a live object on the heap for as long as the searcher lives.
What each cache holds. The sizes are entry counts, not bytes — the bytes depend on your index.
The filterCache is the one that surprises people, because its entries are sized by the index and not by the filter. A filter matching a large share of the documents is kept as a bitset of one bit per document, so on a 10 million document index a single entry can be around 1.25 MB. Configure size="512" and you have authorised roughly 640 MB of heap for that cache alone. On a small index the same setting costs almost nothing. The number to think about is not the cache size, it is the cache size multiplied by your document count.
<query> <!-- entry counts, not megabytes. autowarmCount=0 means a new searcher starts cold instead of replaying old queries while the old searcher is still holding its heap. --> <filterCache size="512" initialSize="512" autowarmCount="0"/> <queryResultCache size="512" initialSize="512" autowarmCount="0"/> <documentCache size="512" initialSize="512" autowarmCount="0"/> <!-- how many documents of a result page are worth caching at all --> <queryResultWindowSize>20</queryResultWindowSize> <queryResultMaxDocsCached>200</queryResultMaxDocsCached> </query>
Start small and measure, do not start large and hope
Cache hit ratios are visible per index in the Solr admin interface. A cache with a low hit ratio is pure heap cost; a cache with a high hit ratio and evictions is the one worth growing.
Autowarming is not free
While a new searcher warms, the old one is still open and both hold their caches. Aggressive autowarmCount values on an index that commits often are a classic way to run two full cache sets at once.
Cache classes changed in Solr 9
Every cache is now solr.CaffeineCache. A config carried over from Solr 8 that names solr.FastLRUCache or solr.LRUCache will not load — see ClassNotFoundException: solr.FastLRUCache.
Solr best practices
Cache sizing (this page)