š§ Solr RAM & Memory Management: Best Practices (or, āHow Not to Blow Up Your Serverā)
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.
Why Does Solr Use So Much RAM?
Solr eats memory to build search results, cache data, and keep things fast.
But:
- Bad configuration or huge, inefficient requests can cause even the biggest server to choke and burn through RAM.
- Sometimes, small indexes on giant machines will still crash if your setup isnāt right.
- Good news: Opensolr has self-healingāif Solr crashes, itāll be back in under a minute. Still, prevention is better than panic.
š§ Essential Best Practices
1. Save Transfer Bandwidth (and Memory)
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.
2. Donāt Ask Solr to Return 10 Million Results
- Requesting thousands of docs in one go?
That makes Solr allocate all that data, and cache it, too. - Solution: Keep the
rowsparameter below 100 for most queries.
Example:&rows=100
3. Paginate Responsibly (Or: Donāt Scroll to Infinity)
- If youāre paginating over millions of docs (like
&start=500000&rows=100), Solr has to allocate a ton of memory for all those results. - Solution: Try to keep
startunder 50,000 if possible. - The more stored fields you have in your schema, the more RAM will be used for large paginations.
4. Heavy Faceting, Sorting, Highlighting, or Grouping? Use docValues=true
-
Operations like faceting, sorting, highlighting, and grouping can be memory hogs.
-
Solution: Define your fields with
docValues="true"inschema.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" />
5. Donāt Go Cache-Crazy
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.xmland keep sizes low. -
Example:
<filterCache size="1" initialSize="1" autowarmCount="0"/>
6. Using Drupal?
- Always update your Search API Solr module to the latest version!
- Thereās a known bug that can cause headachesāstay patched!
š¤ Final Wisdom
- RAM is precious. Donāt let Solr treat it like an all-you-can-eat buffet.
- Optimize requests, paginate wisely, and keep configs tight.
- If Solr OOMs (āOut of Memoryā)āOpensolrās got your back, but wouldnāt you rather avoid the drama?
Questions? Want a config review or more tips? Contact the Opensolr team!

