Solr is a beast—it loves RAM like a dog loves a steak. If your Solr server is gobbling up memory and crashing, don’t panic! Here’s what you need to know, plus battle-tested ways to keep things lean, mean, and not out-of-memory.
Solr eats memory to build search results, cache data, and keep things fast.
But:
Want to save bandwidth and RAM? Read these tips.
Optimizing your queries is a win-win: less data in and out, and less stress on your server.
rows parameter below 100 for most queries.&rows=100
&start=500000&rows=100), Solr has to allocate a ton of memory for all those results.start under 50,000 if possible.docValues=trueOperations like faceting, sorting, highlighting, and grouping can be memory hogs.
Solution: Define your fields with docValues="true" in schema.xml.
Example:
<field name="name" docValues="true" type="text_general" indexed="true" stored="true" />
For highlighting, you may want even more settings:
<field name="description" type="text_general" indexed="true" stored="true" docValues="true" termVectors="true" termPositions="true" termOffsets="true" storeOffsetsWithPositions="true" />
Solr caches are great... until they eat all your memory and leave nothing for real work.
The big four:
filterCache: stores document ID lists for filter queries (fq)queryResultCache: stores doc IDs for search resultsdocumentCache: caches stored field valuesfieldCache: stores all values for a field in memory (dangerous for big fields!)Solution: Tune these in solrconfig.xml and keep sizes low.
Example:
<filterCache size="1" initialSize="1" autowarmCount="0"/>
Questions? Want a config review or more tips? Contact the Opensolr team!