# Uneven Primary Shard Distribution

**URL:** <https://discuss.elastic.co/t/uneven-primary-shard-distribution/152755>\
**Category:** Elasticsearch\
**Created:** [October 17, 2018, 5:38am UTC](https://discuss.elastic.co/t/uneven-primary-shard-distribution/152755 "2018-10-17T05:38:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sam\_Wang](https://avatars.discourse-cdn.com/v4/letter/s/96bed5/32.png) [@Sam\_Wang](https://discuss.elastic.co/u/Sam_Wang)\
**Post date:** [October 17, 2018, 5:38am UTC](https://discuss.elastic.co/t/uneven-primary-shard-distribution/152755/1 "2018-10-17T05:38:47Z")

</div>

Hi, I'm experiencing a problem to do with uneven primary shards across datanodes, for some reason, all the primary shards are just going to the same datanode, regardless all the datanodes are running on the same version and also not caped on resources.

Currently, I just manually reshuffle the shards to get the loads off that node, hopefully, anyone help can give some help and information regarding to this.

I have attached screenshots of the stats of the cluster, any help/information would be much appreciated

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/e/0/e007aef9cc3cb160cd2fdc3bff28e963c0322cb0.png)

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/a/e/aea375b79cae3e3e39eeb65ea0c626b2fd397c6a.png)

\_cluster/settings

{  
"persistent": {

},  
"transient": {  
"cluster": {  
"routing": {  
"allocation": {  
"enable": "all",  
"exclude": {  
"\_ip": "10.0.0.1,10.0.0.2"  
}  
}  
}  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [October 17, 2018, 7:11am UTC](https://discuss.elastic.co/t/uneven-primary-shard-distribution/152755/2 "2018-10-17T07:11:28Z")

</div>

Can you explain what problem you are seeing with primary shards being on one node and why you think you need to spread them properly? Why do you think that primary shards have a higher load than replicas? Both need to do the same indexing work and both are used for searching.

---

<div class="post-metadata">

**Author:** ![Sam\_Wang](https://avatars.discourse-cdn.com/v4/letter/s/96bed5/32.png) [@Sam\_Wang](https://discuss.elastic.co/u/Sam_Wang)\
**Post date:** [October 17, 2018, 11:14pm UTC](https://discuss.elastic.co/t/uneven-primary-shard-distribution/152755/3 "2018-10-17T23:14:58Z")

</div>

Hi Alexander,

After careful read at your questions, I think the questions I asked is wrong and misleading. Instead, I should have asked why the shards distribution is uneven and why all the primary shards are going to the same node. sorry about that ...

When the time I have problems with ingestion, seems like the majority of shards are going the same node, and all shards on that node are primary, so that's why I naively think to myself primary shard create more load.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/2/d/2d6f5b3bbb6ab6e1a863d2b62fd480707964917a.png)

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [October 18, 2018, 7:20am UTC](https://discuss.elastic.co/t/uneven-primary-shard-distribution/152755/4 "2018-10-18T07:20:44Z")

</div>

A primary and a replica shard have exactly the same load on indexing. A document gets indexed first on the primary and if successful on all of the replicas, doing the same amount of work.

Regarding the balanced shards. It may happen that all your primary shards end up on the same node, if you start/stop nodes, so that replica relocation happens on the other nodes. The shard allocation decision is based on a number of factors, so pretty hard to squeeze in a forum post.

---

<div class="post-metadata">

**Author:** ![dqirvin](https://avatars.discourse-cdn.com/v4/letter/d/a88e57/32.png) [@dqirvin](https://discuss.elastic.co/u/dqirvin)\
**Post date:** [November 1, 2018, 11:27pm UTC](https://discuss.elastic.co/t/uneven-primary-shard-distribution/152755/5 "2018-11-01T23:27:26Z")

</div>

The problem is in the step you mention about being indexed on the primary first.

This is a bottle neck for indexing as all the requests to index and update are sent to a single node.

The bulk update queue fills up, and ultimately on my system we see rejections. When a node goes down, the all primaries are concentrated to another node.... then this node is bombarded..... and it continues until the cluster is in poor health.

---

<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:** [November 29, 2018, 11:27pm UTC](https://discuss.elastic.co/t/uneven-primary-shard-distribution/152755/6 "2018-11-29T23:27:36Z")

</div>

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