# High elastic search heap memory consumption while indexing huge files

**URL:** https://discuss.elastic.co/t/high-elastic-search-heap-memory-consumption-while-indexing-huge-files/98004
**Category:** Elasticsearch
**Created:** [August 23, 2017, 6:26am UTC](https://discuss.elastic.co/t/high-elastic-search-heap-memory-consumption-while-indexing-huge-files/98004 "2017-08-23T06:26:38Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![akash](https://avatars.discourse-cdn.com/v4/letter/a/a5b964/32.png) [@akash](https://discuss.elastic.co/u/akash)
#### Post date: [August 23, 2017, 6:26am UTC](https://discuss.elastic.co/t/high-elastic-search-heap-memory-consumption-while-indexing-huge-files/98004/1 "2017-08-23T06:26:39Z")

</div>

Hi,  
We are trying to index large files in elastic search. Elastic heap memory consumption shoots up while indexing.

Basic observation is that while indexing memory can go upto 30x and post indexing it remains at around 10x.  
For eg: while indexing 600MB file, memory usage is around 6GB and it can shoot upto 18 GB.  
while indexing 1GB file, memory usage is around 10GB and it can shoot upto 30 GB.

Is this expected behaviour. Is there a way we can reduce the memory footprint.

Any help with this query is highly appreciated.

This behavior is seen in both ES 2.4 and ES 5.5 versions

2 data nodes, 1 dedicated master node.  
ES Heap memory - 31 GB in all nodes

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [August 23, 2017, 8:57am UTC](https://discuss.elastic.co/t/high-elastic-search-heap-memory-consumption-while-indexing-huge-files/98004/2 "2017-08-23T08:57:25Z")

</div>

How are you indexing the data? How large are your documents? How large are your bulk requests? How many concurrent indexing threads do you use?

---

<div class="post-metadata">

### Author: ![akash](https://avatars.discourse-cdn.com/v4/letter/a/a5b964/32.png) [@akash](https://discuss.elastic.co/u/akash)
#### Post date: [August 23, 2017, 9:12am UTC](https://discuss.elastic.co/t/high-elastic-search-heap-memory-consumption-while-indexing-huge-files/98004/3 "2017-08-23T09:12:49Z")

</div>

Hi Christian,

Please find details below -

How are you indexing the data?

> > _We are calling **bulk indexing API** using curl command. We initially tried with transport client, but we were getting OutOfMemoryError._

How large are your documents?

> > _We have tested with 600 MB and 1 GB data._

How large are your bulk requests?

> > _We were trying to index a single document of 1 GB data. Document contains single key value pair._

How many concurrent indexing threads do you use?

> > _Not sure about this. How to find this out_

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [August 23, 2017, 9:21am UTC](https://discuss.elastic.co/t/high-elastic-search-heap-memory-consumption-while-indexing-huge-files/98004/4 "2017-08-23T09:21:07Z")

</div>

Questions around indexing very large documents have been asked before on the forum. Please have a look at:

> [@Recommendation for indexing a large size document \< 1G](https://discuss.elastic.co/t/recommendation-for-indexing-a-large-size-document-1g/28880):
>
> Hi ES Team, This question may have been asked earlier. I am looking for ways to index really large documents like PDF, Word using ES. Our application crawls enterprise Active Directory system and we have hit some really large documents that we are unable to index as of now. We are seeing OutOfMemory Error in ES logs. I must also mention that for large files we pass a URL to a custom plugin running within ES server. This plugin reads the entire source file into memory from the provided URL befor…

> [@Elastic search memory heap exception when trying to index large document by chunks](https://discuss.elastic.co/t/elastic-search-memory-heap-exception-when-trying-to-index-large-document-by-chunks/65924):
>
> Hello there, Setup: the elastic search version that we are using is 2.3.5 we set es java heap size to be 4GB and then set bootstrap.mlockall: true UseCase: We have a use case where we would like to index very large document like 1GB using mapper-attachment plugin. We know that memory is going to be an issue so we are sending the 1 GB files into smaller chunks of 50MB into elastic search synchronously. To append the chunks to elastic i have used append script as shown below: var updateRe…

---

<div class="post-metadata">

### Author: ![akash](https://avatars.discourse-cdn.com/v4/letter/a/a5b964/32.png) [@akash](https://discuss.elastic.co/u/akash)
#### Post date: [August 23, 2017, 9:35am UTC](https://discuss.elastic.co/t/high-elastic-search-heap-memory-consumption-while-indexing-huge-files/98004/5 "2017-08-23T09:35:33Z")

</div>

Above links are similar to our requirement where we need to index large documents. They are suggesting to split the document which would add complexity to search part.

Any idea why while indexing heap memory goes up to 30 x and post indexing it remains at around 10 x ??

Is there any settings we can change in order to reduce memory usage, say around 3 x or 4 x.

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [August 23, 2017, 9:45am UTC](https://discuss.elastic.co/t/high-elastic-search-heap-memory-consumption-while-indexing-huge-files/98004/6 "2017-08-23T09:45:06Z")

</div>

I am not surprised the heap usage grows a lot as there is a lot of analysis and processing going on. As mentioned in the links I provided, documents of that size is really beyond what Elasticsearch was designed for and you may also face issue searching them.

---

<div class="post-metadata">

### Author: ![akash](https://avatars.discourse-cdn.com/v4/letter/a/a5b964/32.png) [@akash](https://discuss.elastic.co/u/akash)
#### Post date: [August 23, 2017, 10:14am UTC](https://discuss.elastic.co/t/high-elastic-search-heap-memory-consumption-while-indexing-huge-files/98004/7 "2017-08-23T10:14:54Z")

</div>

Ok Thanks a lot for the information.

---

<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: [September 20, 2017, 10:15am UTC](https://discuss.elastic.co/t/high-elastic-search-heap-memory-consumption-while-indexing-huge-files/98004/8 "2017-09-20T10:15:01Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
