# Does Elasticsearch ensures that all the replica shards are distributed in other data nodes?

**URL:** <https://discuss.elastic.co/t/does-elasticsearch-ensures-that-all-the-replica-shards-are-distributed-in-other-data-nodes/155149>\
**Category:** Elasticsearch\
**Created:** [November 2, 2018, 10:51am UTC](https://discuss.elastic.co/t/does-elasticsearch-ensures-that-all-the-replica-shards-are-distributed-in-other-data-nodes/155149 "2018-11-02T10:51:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![melvilgit](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/melvilgit/32/37233_2.png) [@melvilgit](https://discuss.elastic.co/u/melvilgit)\
**Post date:** [November 2, 2018, 10:51am UTC](https://discuss.elastic.co/t/does-elasticsearch-ensures-that-all-the-replica-shards-are-distributed-in-other-data-nodes/155149/1 "2018-11-02T10:51:25Z")

</div>

Does Elasticsearch automatically ensures that all the replica shards are distributed in other data nodes irrespective of the number of shards and no of data nodes ?

Say I have 3 ES nodes and For an Index A , I have 10 shards,  
Assuming the primary shards is Distributed uniformly in 3 ES Boxes  
My question is Does Elasticsearch distributes the replica shards of the 10 primary shards in such a way that If any of the box out of the 3 ES Nodes went down , the data loss won't happens ?

---

<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:** [November 2, 2018, 10:54am UTC](https://discuss.elastic.co/t/does-elasticsearch-ensures-that-all-the-replica-shards-are-distributed-in-other-data-nodes/155149/2 "2018-11-02T10:54:08Z")

</div>

Yes, a replica shard will never be allocated to the same node as the corresponding primary shard.

---

<div class="post-metadata">

**Author:** ![melvilgit](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/melvilgit/32/37233_2.png) [@melvilgit](https://discuss.elastic.co/u/melvilgit)\
**Post date:** [November 2, 2018, 11:02am UTC](https://discuss.elastic.co/t/does-elasticsearch-ensures-that-all-the-replica-shards-are-distributed-in-other-data-nodes/155149/3 "2018-11-02T11:02:56Z")

</div>

So If I have X number of Data Nodes and Y no of Shards with Z No of Replication Factor ,  
ES guarantees Failure of Any Boxes in X won't causes any data loss ?

To be clear ,Say If I have 3 Nodes and 4 shard for my index , Then then the primary and replica shard will  
be distributed as below [p - Primary Shard and r-Replica Shard]

Node 1 - [p1, r2 , r4] Node 2 =[p2 , r3] Node 3 - [p3 , p4 , r1] ,  
So that failure of any nodes won't cause chaos !

---

<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 30, 2018, 11:03am UTC](https://discuss.elastic.co/t/does-elasticsearch-ensures-that-all-the-replica-shards-are-distributed-in-other-data-nodes/155149/4 "2018-11-30T11:03:00Z")

</div>

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