# How does ES balance memory usage?

**URL:** <https://discuss.elastic.co/t/how-does-es-balance-memory-usage/3943>\
**Category:** Elasticsearch\
**Created:** [February 18, 2011, 1:11am UTC](https://discuss.elastic.co/t/how-does-es-balance-memory-usage/3943 "2011-02-18T01:11:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jalano](https://avatars.discourse-cdn.com/v4/letter/j/e56c9b/32.png) [@jalano](https://discuss.elastic.co/u/jalano)\
**Post date:** [February 18, 2011, 1:11am UTC](https://discuss.elastic.co/t/how-does-es-balance-memory-usage/3943/1 "2011-02-18T01:11:57Z")

</div>

I have 8 nodes in my cluster, but I noticed that the memory usage is  
pretty un-even once all of my documents are indexed. That by itself  
doesn't bother me, but I am getting worried because I noticed that as  
I've been populating a new index, the node that is almost full for  
some reason seems to want to attract a lot more documents to it! 🙂  
It's actually starting to garbage collect more often than the other  
nodes (not too often, just twice a day).

My question is - when/if that node runs _really_ low on memory will ES  
start filling the other nodes? Is there some kind of threshold (95%  
full) where ES will stop attempting to drop more documents on this  
node?

Several of my other nodes are less than 25% full and could easily  
handle more.

---

<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:** [February 20, 2011, 1:09am UTC](https://discuss.elastic.co/t/how-does-es-balance-memory-usage/3943/2 "2011-02-20T01:09:43Z")

</div>

Heya,

The way elasticsearch balance across a cluster is based on shards. It strives to keep an even number of shards across the nodes in the cluster. Memory consumption wise its kindda difficult to judge in a VM based language with garbage collector, since things might be good, just more memory was cleared on a node compared to others.

Other balancing schemes (for example, trying to strive to keep an even number of docs across the cluster, or balanced storage) can be implemented in future versions.

-shay.banon  
On Friday, February 18, 2011 at 3:11 AM, jalano wrote:

> I have 8 nodes in my cluster, but I noticed that the memory usage is  
> pretty un-even once all of my documents are indexed. That by itself  
> doesn't bother me, but I am getting worried because I noticed that as  
> I've been populating a new index, the node that is almost full for  
> some reason seems to want to attract a lot more documents to it! 🙂  
> It's actually starting to garbage collect more often than the other  
> nodes (not too often, just twice a day).
> 
> My question is - when/if that node runs _really_ low on memory will ES  
> start filling the other nodes? Is there some kind of threshold (95%  
> full) where ES will stop attempting to drop more documents on this  
> node?
> 
> Several of my other nodes are less than 25% full and could easily  
> handle more.

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [February 20, 2011, 8:54am UTC](https://discuss.elastic.co/t/how-does-es-balance-memory-usage/3943/3 "2011-02-20T08:54:35Z")

</div>

> Other balancing schemes (for example, trying to strive to keep an  
> even number of docs across the cluster, or balanced storage) can be  
> implemented in future versions.

Or just a simple weighting that can be set per server?

clint

---

<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, 4:11am UTC](https://discuss.elastic.co/t/how-does-es-balance-memory-usage/3943/4 "2017-07-06T04:11:48Z")

</div>


