# HEAP Size in ESXi\`s VM

**URL:** <https://discuss.elastic.co/t/heap-size-in-esxi-s-vm/26852>\
**Category:** Elasticsearch\
**Created:** [August 5, 2015, 8:07am UTC](https://discuss.elastic.co/t/heap-size-in-esxi-s-vm/26852 "2015-08-05T08:07:35Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Max\_Just](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@Max\_Just](https://discuss.elastic.co/u/Max_Just)\
**Post date:** [August 5, 2015, 8:07am UTC](https://discuss.elastic.co/t/heap-size-in-esxi-s-vm/26852/1 "2015-08-05T08:07:35Z")

</div>

Hi everybody,  
Should I dedicate for JAVA HEAP size a half of memory like in real machines if I use elasticsearch in VM under ESXi? Or I can use all of memory for JAVA HEAP size?

---

<div class="post-metadata">

**Author:** ![Andrei\_Stefan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrei_stefan/32/47533_2.png) [@Andrei\_Stefan](https://discuss.elastic.co/u/Andrei_Stefan)\
**Post date:** [August 5, 2015, 8:45am UTC](https://discuss.elastic.co/t/heap-size-in-esxi-s-vm/26852/2 "2015-08-05T08:45:03Z")

</div>

Just like on bare metal: half RAM at most.  
And be careful not to overallocate resources (CPU, memory) in your VMware virtualization. If your VMs will use everything configured for them to use, and you do over-allocate, the virtualization software will swap. Swap is never desired when using Elasticsearch.

---

<div class="post-metadata">

**Author:** ![Max\_Just](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@Max\_Just](https://discuss.elastic.co/u/Max_Just)\
**Post date:** [August 5, 2015, 9:58am UTC](https://discuss.elastic.co/t/heap-size-in-esxi-s-vm/26852/3 "2015-08-05T09:58:20Z")

</div>

About RAM absolutelly right, but why I can`t overlocate CPU resources?

---

<div class="post-metadata">

**Author:** ![Andrei\_Stefan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrei_stefan/32/47533_2.png) [@Andrei\_Stefan](https://discuss.elastic.co/u/Andrei_Stefan)\
**Post date:** [August 5, 2015, 10:06am UTC](https://discuss.elastic.co/t/heap-size-in-esxi-s-vm/26852/4 "2015-08-05T10:06:29Z")

</div>

Because Elasticsearch creates thread pools with a size that's calculated relative to the number of CPU cores it detects on the machine (VM in your case).

So, if you design your cluster with a load in mind (searching, indexing etc) and you expect X ms response time, then this time is affected by the over-allocation of CPU. Even if you give 8 cores to your VM for example, and ES creates those thread pools considering this value, if ESXi decides to take some of the computing power from the ES VM then the response times will suffer.

---

<div class="post-metadata">

**Author:** ![Max\_Just](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@Max\_Just](https://discuss.elastic.co/u/Max_Just)\
**Post date:** [August 5, 2015, 10:14am UTC](https://discuss.elastic.co/t/heap-size-in-esxi-s-vm/26852/5 "2015-08-05T10:14:28Z")

</div>

I have 3 VM with 8 cores in 24 core host. and Now I have a 20% load of my CPU on ESXi host. LA near 2.5. I think what If I add 2 VM with 8 cores it will be more better. Because elastic do not use all shards on all VM at the same time. Isn't it?

---

<div class="post-metadata">

**Author:** ![Andrei\_Stefan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrei_stefan/32/47533_2.png) [@Andrei\_Stefan](https://discuss.elastic.co/u/Andrei_Stefan)\
**Post date:** [August 5, 2015, 10:18am UTC](https://discuss.elastic.co/t/heap-size-in-esxi-s-vm/26852/6 "2015-08-05T10:18:56Z")

</div>

Why wouldn't use all the shards?  
Elasticsearch uses a single shard copy (primary or replica) of a shard when searching for example. What if you want to search all your indices? Doesn't this mean you will most likely use shards from all the nodes at the same time?

3 VMs with 8 cores each on a 24 cores machine is ok. But the recommendation is not to over-allocate.

---

<div class="post-metadata">

**Author:** ![Max\_Just](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@Max\_Just](https://discuss.elastic.co/u/Max_Just)\
**Post date:** [August 5, 2015, 10:26am UTC](https://discuss.elastic.co/t/heap-size-in-esxi-s-vm/26852/7 "2015-08-05T10:26:19Z")

</div>

I think you right. thanks for your reply.

---

<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 5, 2017, 11:57pm UTC](https://discuss.elastic.co/t/heap-size-in-esxi-s-vm/26852/8 "2017-07-05T23:57:18Z")

</div>


