# Soft field data cache isn't evicting data?

**URL:** https://discuss.elastic.co/t/soft-field-data-cache-isnt-evicting-data/6962
**Category:** Elasticsearch
**Created:** [March 9, 2012, 6:37pm UTC](https://discuss.elastic.co/t/soft-field-data-cache-isnt-evicting-data/6962 "2012-03-09T18:37:18Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Dustin\_Shields\_Cloue](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dustin_shields_cloue/32/2963_2.png) [@Dustin\_Shields\_Cloue](https://discuss.elastic.co/u/Dustin_Shields_Cloue)
#### Post date: [March 9, 2012, 6:37pm UTC](https://discuss.elastic.co/t/soft-field-data-cache-isnt-evicting-data/6962/1 "2012-03-09T18:37:18Z")

</div>

I'm load testing a reporting service that will allow users to run  
arbitrarily-generated facets against a large set of data (~100m new records  
per day, using daily index rotation). We have a 3-node ES cluster, with  
72GB ram each (half allocated to ES, half reserved for the OS and disk  
cache). We're running ES 0.18.7.

I'm seeing regular out of memory errors that result in a particular node  
locking up and dropping out of the cluster. Flushing the field cache or  
fully restarting the node brings everything back into a good state, but I'd  
rather avoid getting into this state in the first place. I tried setting  
index.cache.field.type: soft in /etc/elasticsearch.yml, but this isn't  
having the desired effect - is this not where one sets this? Do I need to  
set it per-index using the index settings api?

I've read elsewhere that regularly evicting entries from the cache is  
undesirable, but I don't see an alternative here - our data set is always  
going to be too large to fit in memory, and I'm willing to accept the  
performance trade-off since most of our faceted queries are relatively  
unique and I'd rather be able to query slowly than worry about crashing ES  
nodes by running out of memory.

I'd rather not write a cron job to flush the caches when memory usage  
creeps up. It definitely sounds like there's a better way, though, and I'm  
just missing something semi-obvious.

Thanks,  
-- Dustin

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [March 9, 2012, 7:12pm UTC](https://discuss.elastic.co/t/soft-field-data-cache-isnt-evicting-data/6962/2 "2012-03-09T19:12:15Z")

</div>

The field cache will be loaded fully for an execution that requires it, so most times (if not all), evicting it makes little sense. Soft field cache relies on the JVM to clear data when it hits memory pressure, but its not really reliable… .

On Friday, March 9, 2012 at 8:37 PM, Dustin Shields-Cloues wrote:

> I'm load testing a reporting service that will allow users to run arbitrarily-generated facets against a large set of data (~100m new records per day, using daily index rotation). We have a 3-node ES cluster, with 72GB ram each (half allocated to ES, half reserved for the OS and disk cache). We're running ES 0.18.7.
> 
> I'm seeing regular out of memory errors that result in a particular node locking up and dropping out of the cluster. Flushing the field cache or fully restarting the node brings everything back into a good state, but I'd rather avoid getting into this state in the first place. I tried setting index.cache.field.type: soft in /etc/elasticsearch.yml, but this isn't having the desired effect - is this not where one sets this? Do I need to set it per-index using the index settings api?
> 
> I've read elsewhere that regularly evicting entries from the cache is undesirable, but I don't see an alternative here - our data set is always going to be too large to fit in memory, and I'm willing to accept the performance trade-off since most of our faceted queries are relatively unique and I'd rather be able to query slowly than worry about crashing ES nodes by running out of memory.
> 
> I'd rather not write a cron job to flush the caches when memory usage creeps up. It definitely sounds like there's a better way, though, and I'm just missing something semi-obvious.
> 
> Thanks,  
> -- Dustin

---

<div class="post-metadata">

### Author: ![Dustin\_Shields\_Cloue](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dustin_shields_cloue/32/2963_2.png) [@Dustin\_Shields\_Cloue](https://discuss.elastic.co/u/Dustin_Shields_Cloue)
#### Post date: [March 9, 2012, 7:26pm UTC](https://discuss.elastic.co/t/soft-field-data-cache-isnt-evicting-data/6962/3 "2012-03-09T19:26:06Z")

</div>

That makes sense - thanks. I _think_ cache eviction does make sense in this  
particular use case: we're storing log data, and our queries tend to be  
concerned with the past few days. We do occasionally run faceted queries  
across larger date ranges, but in general, I don't think we need to be  
concerned with caching fields from days-old indices, since we're so much  
less likely to need to index them. Regardless of how much ram we throw at  
this, our total dataset is always going to to be larger, so I don't see any  
way to cache everything.

It does seem clear, though, that we need to ensure that there's always  
sufficient memory to cache commonly-faceted fields for a few days worth of  
indexes.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 6, 2017, 3:36am UTC](https://discuss.elastic.co/t/soft-field-data-cache-isnt-evicting-data/6962/4 "2017-07-06T03:36:29Z")

</div>


