# Estimating index.cache.field.max\_size

**URL:** https://discuss.elastic.co/t/estimating-index-cache-field-max-size/10028
**Category:** Elasticsearch
**Created:** [December 11, 2012, 5:58am UTC](https://discuss.elastic.co/t/estimating-index-cache-field-max-size/10028 "2012-12-11T05:58:11Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Marcin\_Dojwa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marcin_dojwa/32/2307_2.png) [@Marcin\_Dojwa](https://discuss.elastic.co/u/Marcin_Dojwa)
#### Post date: [December 11, 2012, 5:58am UTC](https://discuss.elastic.co/t/estimating-index-cache-field-max-size/10028/1 "2012-12-11T05:58:11Z")

</div>

Hi,

I have a question: how to estimate index.cache.field.max\_size? Maybe there  
is some kind of equation based on RAM memory, number of shards, ... ? I  
guess that indices.cache.filter.size is quite simple to set because it can  
be a percentage value (default 20% is just fine), but as I understand I  
have to set index.cache.field.max\_size to avoid OutOfMemory errors because  
it is unbounded by default right ?

Thank you.

Best regards.  
Marcin Dojwa

--

---

<div class="post-metadata">

### Author: ![karmi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/karmi/32/44951_2.png) [@karmi](https://discuss.elastic.co/u/karmi)
#### Post date: [December 11, 2012, 8:51am UTC](https://discuss.elastic.co/t/estimating-index-cache-field-max-size/10028/2 "2012-12-11T08:51:16Z")

</div>

> as I understand I have to set index.cache.field.max\_size to avoid  
> OutOfMemory errors because it is unbounded by default

The only way to combat OOM is to observe your memory usage and simply have  
enough RAM to satisfy your requirements.

(I don't think it's easy to guess the optimal value for  
`index.cache.field.max_size`, unless you know very well what you want to  
achieve and know very well your data and usage patterns.)

Karel

On Tuesday, December 11, 2012 6:58:11 AM UTC+1, Marcin Dojwa wrote:

> Hi,
> 
> I have a question: how to estimate index.cache.field.max\_size? Maybe there  
> is some kind of equation based on RAM memory, number of shards, ... ? I  
> guess that indices.cache.filter.size is quite simple to set because it can  
> be a percentage value (default 20% is just fine), but as I understand I  
> have to set index.cache.field.max\_size to avoid OutOfMemory errors because  
> it is unbounded by default right ?
> 
> Thank you.
> 
> Best regards.  
> Marcin Dojwa

--

---

<div class="post-metadata">

### Author: ![Marcin\_Dojwa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marcin_dojwa/32/2307_2.png) [@Marcin\_Dojwa](https://discuss.elastic.co/u/Marcin_Dojwa)
#### Post date: [December 11, 2012, 9:05am UTC](https://discuss.elastic.co/t/estimating-index-cache-field-max-size/10028/3 "2012-12-11T09:05:58Z")

</div>

Thank you, that does not sound to be stable 🙂 I hope that setting  
index.cache.field.type: soft will prevent OOM. Am I wrong? I am just  
testing it 🙂

2012/12/11 Karel Minařík [karel.minarik@gmail.com](mailto:karel.minarik@gmail.com)

> > as I understand I have to set index.cache.field.max\_size to avoid  
> > OutOfMemory errors because it is unbounded by default
> 
> The only way to combat OOM is to observe your memory usage and simply have  
> enough RAM to satisfy your requirements.
> 
> (I don't think it's easy to guess the optimal value for  
> `index.cache.field.max_size`, unless you know very well what you want to  
> achieve and know very well your data and usage patterns.)
> 
> Karel
> 
> On Tuesday, December 11, 2012 6:58:11 AM UTC+1, Marcin Dojwa wrote:
> 
> > Hi,
> > 
> > I have a question: how to estimate index.cache.field.max\_size? Maybe  
> > there is some kind of equation based on RAM memory, number of shards, ... ?  
> > I guess that indices.cache.filter.size is quite simple to set because it  
> > can be a percentage value (default 20% is just fine), but as I understand I  
> > have to set index.cache.field.max\_size to avoid OutOfMemory errors because  
> > it is unbounded by default right ?
> > 
> > Thank you.
> > 
> > Best regards.  
> > Marcin Dojwa
> 
> --

--

---

<div class="post-metadata">

### Author: ![karmi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/karmi/32/44951_2.png) [@karmi](https://discuss.elastic.co/u/karmi)
#### Post date: [December 11, 2012, 9:52am UTC](https://discuss.elastic.co/t/estimating-index-cache-field-max-size/10028/4 "2012-12-11T09:52:50Z")

</div>

> Thank you, that does not sound to be stable 🙂

What do you mean?

> I hope that setting index.cache.field.type: soft will prevent OOM. Am I  
> wrong? I am just testing it 🙂

Yes 🙂 That means you're throwing out all the expensively loaded data into  
memory.

Karel

--

---

<div class="post-metadata">

### Author: ![Marcin\_Dojwa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marcin_dojwa/32/2307_2.png) [@Marcin\_Dojwa](https://discuss.elastic.co/u/Marcin_Dojwa)
#### Post date: [December 11, 2012, 12:17pm UTC](https://discuss.elastic.co/t/estimating-index-cache-field-max-size/10028/5 "2012-12-11T12:17:58Z")

</div>

> Yes 🙂 That means you're throwing out all the expensively loaded data  
> into memory.  
> Here I can throw it out or get OOM right ? 🙂

I think I understand it all now 🙂 When I have field cache type set to  
'soft' I no longer get OOM but GC gets almost all the processor time when  
heap-memory ends. I set cache.field.expire to 10m now and checking if this  
is enough. As I understand I have to set expire and max\_size parameters to  
avoid getting the heap-memory almost full right ?

Best regards.

2012/12/11 Karel Minařík [karel.minarik@gmail.com](mailto:karel.minarik@gmail.com)

> > Thank you, that does not sound to be stable 🙂
> 
> What do you mean?
> 
> > I hope that setting index.cache.field.type: soft will prevent OOM. Am I  
> > wrong? I am just testing it 🙂
> 
> Yes 🙂 That means you're throwing out all the expensively loaded data into  
> memory.
> 
> Karel
> 
> --

--

---

<div class="post-metadata">

### Author: ![karmi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/karmi/32/44951_2.png) [@karmi](https://discuss.elastic.co/u/karmi)
#### Post date: [December 11, 2012, 2:34pm UTC](https://discuss.elastic.co/t/estimating-index-cache-field-max-size/10028/6 "2012-12-11T14:34:43Z")

</div>

> Here I can throw it out or get OOM right ? 🙂
> 
> I think I understand it all now 🙂 When I have field cache type set to 'soft' I no longer get OOM but GC gets almost all the processor time when heap-memory ends. I set cache.field.expire to 10m now and checking if this is enough. As I understand I have to set expire and max\_size parameters to avoid getting the heap-memory almost full right ?

It depends on what you want to achieve... The optimal way to use Elasticsearch is to simply have enough RAM to support your requirements (queries, sorting, facets, etc). So, depending on your use case, you might want to to set these limits and pay the cost of re-building your cache. (Most people, though, are balancing their requirements against available resources, tuning the performance of their search requests, and/or limiting the number the documents.)

Karel

--

---

<div class="post-metadata">

### Author: ![Marcin\_Dojwa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marcin_dojwa/32/2307_2.png) [@Marcin\_Dojwa](https://discuss.elastic.co/u/Marcin_Dojwa)
#### Post date: [December 11, 2012, 2:48pm UTC](https://discuss.elastic.co/t/estimating-index-cache-field-max-size/10028/7 "2012-12-11T14:48:22Z")

</div>

OK, I understand, thank you Karel.

2012/12/11 Karel Minařík [karel.minarik@gmail.com](mailto:karel.minarik@gmail.com)

> > Here I can throw it out or get OOM right ? 🙂
> > 
> > I think I understand it all now 🙂 When I have field cache type set to  
> > 'soft' I no longer get OOM but GC gets almost all the processor time when  
> > heap-memory ends. I set cache.field.expire to 10m now and checking if this  
> > is enough. As I understand I have to set expire and max\_size parameters to  
> > avoid getting the heap-memory almost full right ?
> 
> It depends on what you want to achieve... The optimal way to use  
> Elasticsearch is to simply have enough RAM to support your requirements  
> (queries, sorting, facets, etc). So, depending on your use case, you might  
> want to to set these limits and pay the cost of re-building your cache.  
> (Most people, though, are balancing their requirements against available  
> resources, tuning the performance of their search requests, and/or limiting  
> the number the documents.)
> 
> Karel
> 
> --

--

---

<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:00am UTC](https://discuss.elastic.co/t/estimating-index-cache-field-max-size/10028/8 "2017-07-06T03:00:17Z")

</div>


