# Heap Size setting in k8s

**URL:** <https://discuss.elastic.co/t/heap-size-setting-in-k8s/281522>\
**Category:** Elastic Cloud on Kubernetes (ECK)\
**Created:** [August 16, 2021, 9:39am UTC](https://discuss.elastic.co/t/heap-size-setting-in-k8s/281522 "2021-08-16T09:39:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![purushothamkdr143](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/purushothamkdr143/32/90242_2.png) [@purushothamkdr143](https://discuss.elastic.co/u/purushothamkdr143)\
**Post date:** [August 16, 2021, 9:39am UTC](https://discuss.elastic.co/t/heap-size-setting-in-k8s/281522/1 "2021-08-16T09:39:35Z")

</div>

Hi All,

I am trying to setup up elasticsearch(version 6.8.14) on k8s using eck operator. As per the documentation HEAP SIZE should be 50% of RAM.

1. so If set ( requests, limits as 16GB) then ES\_JAVA\_OPTS should be 8 i.e Xms & xms should be 8GB. is my understanding correct?

2. what happens if I allocate more Heapsize( for ex: 14GB Heapsize out of 16GB total RAM)? Does this configurations slows down querying or data ingestion?

---

<div class="post-metadata">

**Author:** ![michael.morello](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael.morello/32/47448_2.png) [@michael.morello](https://discuss.elastic.co/u/michael.morello)\
**Post date:** [August 16, 2021, 10:02am UTC](https://discuss.elastic.co/t/heap-size-setting-in-k8s/281522/2 "2021-08-16T10:02:40Z")

</div>

Hi,

1. Yes
2. Both the JVM and Elasticsearch require native memory to store data outside of the heap. The JVM process can be killed by the OOM Killer if a memory allocation in the non-heap space exceeds the memory limit.

---

<div class="post-metadata">

**Author:** ![purushothamkdr143](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/purushothamkdr143/32/90242_2.png) [@purushothamkdr143](https://discuss.elastic.co/u/purushothamkdr143)\
**Post date:** [August 16, 2021, 11:57am UTC](https://discuss.elastic.co/t/heap-size-setting-in-k8s/281522/3 "2021-08-16T11:57:16Z")

</div>

Hi Micheal,

Thanks for detailed info.

In Mycase Elasticsearch data node pods are keep restarting, from the logs I figured out the below error.

## Error

org.elasticsearch.transport.ConnectTransportException: [node-3][10.244.8.2:9300] connect\_exception

at org.elasticsearch.transport.TcpTransport$ChannelsConnectedListener.onFailure(TcpTransport.java:1309) ~[elasticsearch-6.8.14.jar:6.8.14]

at org.elasticsearch.action.ActionListener.lambda$toBiConsumer$2(ActionListener.java:101) ~[elasticsearch-6.8.14.jar:6.8.14]

at org.elasticsearch.common.concurrent.CompletableContext.lambda$addListener$0(CompletableContext.java:42) ~[elasticsearch-core-6.8.14.jar:6.8.14]

at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:859) ~[?:?]

at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:837) ~[?:?]

at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506) ~[?:?]

at java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:2152) ~[?:?]

at org.elasticsearch.common.concurrent.CompletableContext.completeExceptionally(CompletableContext.java:57) ~[elasticsearch-core-6.8.14.jar:6.8.14]

at org.elasticsearch.transport.netty4.Netty4TcpChannel.lambda$new$1(Netty4TcpChannel.java:72) ~[?:?]

at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:511) ~[?:?]

at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:504) ~[?:?]

at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:483) ~[?:?]

at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:424) ~[?:?]

at io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:121) ~[?:?]

at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.fulfillConnectPromise(AbstractNioChannel.java:327) ~[?:?]

at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:343) ~[?:?]

at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:644) ~[?:?]

at io.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:556) ~[?:?]

at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:510) ~[?:?]

at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:470) ~[?:?]

at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:909) ~[?:?]

at java.lang.Thread.run(Thread.java:832) [?:?]

Caused by: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: 10.244.8.2/10.244.8.2:9300

at sun.nio.ch.Net.pollConnect(Native Method) ~[?:?]

at sun.nio.ch.Net.pollConnectNow(Net.java:660) ~[?:?]

at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:875) ~[?:?]

at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:327) ~[?:?]

at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:340) ~[?:?]

... 6 more

Caused by: java.net.ConnectException: Connection refused

at sun.nio.ch.Net.pollConnect(Native Method) ~[?:?]

at sun.nio.ch.Net.pollConnectNow(Net.java:660) ~[?:?]

at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:875) ~[?:?]

at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:327) ~[?:?]

at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:340) ~[?:?]

... 6 more

* * *

Not sure is what is causing this? I have ran below api call to see the cpu,ram specifications ?

[https://es:9200/\_cat/nodesv&h=ip,heap.current,heap.percent,heap.max,ram.current,ram.percent,ram.max](https://es:9200/_cat/nodesv&h=ip,heap.current,heap.percent,heap.max,ram.current,ram.percent,ram.max)

output below:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/4/9/49e61ef57809e4799a2951bd8a801ecf4ce7b3ee.png)

looks like RAM has been completely utilized  
Total RAM - 16GB  
HEAPSIZE - 14GB

Is More heapsize & less non-heapsize causing data nodes pods to restart?

---

<div class="post-metadata">

**Author:** ![michael.morello](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael.morello/32/47448_2.png) [@michael.morello](https://discuss.elastic.co/u/michael.morello)\
**Post date:** [August 16, 2021, 12:32pm UTC](https://discuss.elastic.co/t/heap-size-setting-in-k8s/281522/4 "2021-08-16T12:32:42Z")

</div>

> [@purushothamkdr143](#):
>
> Is More heapsize & less non-heapsize causing data nodes pods to restart?

Hard to say without knowing if the process is killed by the Kernel or exiting by itself.  
Keep in mind that by default the JVM is started with `AlwaysPreTouch` which means that even if all the heap is not used the memory cannot be allocated for any other purpose. In your case it means that there is only 2GB of memory remaining to allocate some pages outside of the heap. I would first try to follow the recommendations and see if it prevents nodes from being restarted.

---

<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 13, 2021, 12:33pm UTC](https://discuss.elastic.co/t/heap-size-setting-in-k8s/281522/5 "2021-09-13T12:33:32Z")

</div>

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