# Why shards are not averagely placed in es cluster nodes

**URL:** https://discuss.elastic.co/t/why-shards-are-not-averagely-placed-in-es-cluster-nodes/53208
**Category:** Elasticsearch
**Created:** [June 18, 2016, 4:29pm UTC](https://discuss.elastic.co/t/why-shards-are-not-averagely-placed-in-es-cluster-nodes/53208 "2016-06-18T16:29:32Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![figo10203](https://avatars.discourse-cdn.com/v4/letter/f/e19b73/32.png) [@figo10203](https://discuss.elastic.co/u/figo10203)
#### Post date: [June 18, 2016, 4:29pm UTC](https://discuss.elastic.co/t/why-shards-are-not-averagely-placed-in-es-cluster-nodes/53208/1 "2016-06-18T16:29:32Z")

</div>

Hi,I have a question, when I add two nodes to my es cluster, the shards then relocate at once.  
But the issue is the shards including replica of most index(lighter ones in the graph) are not distributed averagely in the three nodes. I don't know why?  
 ![](https://us1.discourse-cdn.com/elastic/original/2X/e/ea92ea3bfba17ee8e8d082833a4ceb70e00f69e3.png)

 ![](https://us1.discourse-cdn.com/elastic/original/2X/e/e1e0aec8cfcd1e74906de226a701da37ea2c6eaa.png)

I assume that the cluster are not be fully in used. so why and how to change?

little help will be appreciated!

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [June 18, 2016, 4:55pm UTC](https://discuss.elastic.co/t/why-shards-are-not-averagely-placed-in-es-cluster-nodes/53208/2 "2016-06-18T16:55:48Z")

</div>

ES tries to divide all the cluster's shards evenly among the nodes. This means that a given index might be unevenly distributed but as a whole the cluster should be balanced. Still, it looks like your node-3 might be underutilized but judging by your screenshot it might be because its available disk space is above the low watermark level, i.e. the node won't accept shard allocations until the free space goes below the watermark.

What should be of concern to you is that your shards are very small. Each shard in a cluster has a fixed RAM overhead, so you're wasting a lot of memory by having an average shard size of just 25 MB. You should strongly consider reducing the number of shards per index to one. Once your daily index reaches a few gigabytes I'd look into increasing the number of shards.

The optimal shard size depends on other factors, though. If the vast majority of your searches are for data in the last 24 hours it might give better performance to have more than one shard, but if searches often span a couple of days chances are that the workload will be distributed across the cluster's nodes anyway.

Planned cluster growth also plays in. If it's unlikely you'll ever have more than three nodes it's almost certainly wasteful to have more than three shards per index.

---

<div class="post-metadata">

### Author: ![figo10203](https://avatars.discourse-cdn.com/v4/letter/f/e19b73/32.png) [@figo10203](https://discuss.elastic.co/u/figo10203)
#### Post date: [June 21, 2016, 3:46am UTC](https://discuss.elastic.co/t/why-shards-are-not-averagely-placed-in-es-cluster-nodes/53208/3 "2016-06-21T03:46:30Z")

</div>

Thanks a lot magnusbaeck. I am reducing the nodes count back to 1. but the issue now is the shards of the important index "logstash-live" were balanced to three nodes, the new single node just have no shards, I want to ask why and how to move back? copy the /data/ folder to the new one?It seems the structure of data folder of the three nodes are different, one have 1 2 3 4 , one have 0 1 2. so what I can do now?  
 ![](https://us1.discourse-cdn.com/elastic/original/2X/2/24a466873f6922c3a868681369df279fa5d3b632.png)

And the log have below output when I query "logstash-live":

 ![](https://us1.discourse-cdn.com/elastic/original/2X/a/a980674c2c3772af1af437b0e4168d2f5d3bc006.png)

thanks again for your help?

So I add removed nodes again to become a cluster of three nodes, but it seems still the index shards are not allcoated. see the graph.

 ![](https://us1.discourse-cdn.com/elastic/original/2X/8/8c7f69a700eea2628b0cb23e6055f75998650630.png)

---

<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: [June 21, 2016, 6:47am UTC](https://discuss.elastic.co/t/why-shards-are-not-averagely-placed-in-es-cluster-nodes/53208/4 "2016-06-21T06:47:57Z")

</div>

Are all nodes using the same version of Elasticsearch?

---

<div class="post-metadata">

### Author: ![figo10203](https://avatars.discourse-cdn.com/v4/letter/f/e19b73/32.png) [@figo10203](https://discuss.elastic.co/u/figo10203)
#### Post date: [June 21, 2016, 6:58am UTC](https://discuss.elastic.co/t/why-shards-are-not-averagely-placed-in-es-cluster-nodes/53208/5 "2016-06-21T06:58:06Z")

</div>

no, node-1 is es 2.3.1  
node-2 and node-3 is 2.3.3  
Does the different version lead to the unassigned shards?

---

<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: [June 21, 2016, 7:00am UTC](https://discuss.elastic.co/t/why-shards-are-not-averagely-placed-in-es-cluster-nodes/53208/6 "2016-06-21T07:00:56Z")

</div>

Once shards have been allocated to a node with higher version, it may no longer be possible to later relocate them to a lower version, as the Lucene version may differ. It is therefore possible it could affect your scenario. You should always aim to have all nodes in a cluster on the same version.

---

<div class="post-metadata">

### Author: ![figo10203](https://avatars.discourse-cdn.com/v4/letter/f/e19b73/32.png) [@figo10203](https://discuss.elastic.co/u/figo10203)
#### Post date: [June 21, 2016, 7:21am UTC](https://discuss.elastic.co/t/why-shards-are-not-averagely-placed-in-es-cluster-nodes/53208/7 "2016-06-21T07:21:17Z")

</div>

so upgrade node-1 will solve the issue? but why other indices had all their shards assigned.  
If upgrading can work? so how to do that with node-1?  
unzip 2.3.3 tar and copy the /data folder from 2.3.1 to 2.3.3 ?  
Will the operation be secure enough to singlely copy ?

---

<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: [June 21, 2016, 7:26am UTC](https://discuss.elastic.co/t/why-shards-are-not-averagely-placed-in-es-cluster-nodes/53208/8 "2016-06-21T07:26:00Z")

</div>

I am not sure it will solve the issue, but I would upgrade anyway to eliminate it as a possible cause. The best way to upgrade depend on how you initially installed Elasticsearch, so follow the [upgrade guide](https://www.elastic.co/guide/en/elasticsearch/reference/current/rolling-upgrades.html).

---

<div class="post-metadata">

### Author: ![figo10203](https://avatars.discourse-cdn.com/v4/letter/f/e19b73/32.png) [@figo10203](https://discuss.elastic.co/u/figo10203)
#### Post date: [June 21, 2016, 10:01am UTC](https://discuss.elastic.co/t/why-shards-are-not-averagely-placed-in-es-cluster-nodes/53208/9 "2016-06-21T10:01:25Z")

</div>

I upgrade the node-1 to 2.3.3, still, 2 shards are not allocated, I don't know why.  
It is said it might be caused by translog file under /data folder which has conflict . Do you know the /data folder structure among the nodes that may help on solving this?

---

<div class="post-metadata">

### Author: ![figo10203](https://avatars.discourse-cdn.com/v4/letter/f/e19b73/32.png) [@figo10203](https://discuss.elastic.co/u/figo10203)
#### Post date: [June 22, 2016, 1:09am UTC](https://discuss.elastic.co/t/why-shards-are-not-averagely-placed-in-es-cluster-nodes/53208/10 "2016-06-22T01:09:55Z")

</div>

Hi magnusbaeck, any suggestion with my post?

Thanks a lot

---

<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, 10:41pm UTC](https://discuss.elastic.co/t/why-shards-are-not-averagely-placed-in-es-cluster-nodes/53208/11 "2017-07-05T22:41:35Z")

</div>


