# Can you force primary shards to only be on certain nodes, and replica shards on other nodes?

**URL:** <https://discuss.elastic.co/t/can-you-force-primary-shards-to-only-be-on-certain-nodes-and-replica-shards-on-other-nodes/115465>\
**Category:** Elasticsearch\
**Created:** [January 15, 2018, 1:43am UTC](https://discuss.elastic.co/t/can-you-force-primary-shards-to-only-be-on-certain-nodes-and-replica-shards-on-other-nodes/115465 "2018-01-15T01:43:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ankh](https://avatars.discourse-cdn.com/v4/letter/a/ea5d25/32.png) [@ankh](https://discuss.elastic.co/u/ankh)\
**Post date:** [January 15, 2018, 1:43am UTC](https://discuss.elastic.co/t/can-you-force-primary-shards-to-only-be-on-certain-nodes-and-replica-shards-on-other-nodes/115465/1 "2018-01-15T01:43:13Z")

</div>

We have a cluster that will contain a mix of hosts, some with spinning disks and some with SSDs.

We would like to index only to the hosts with spinning disks, and serve queries only from the hosts with SSDs.

How can we force primary shards to only be on the hosts with spinning disks, and replica shards to only be on hosts with SSDs?

I can see it's possible to influence where any shards of an index, both primary and replica, go, but can't see a way to distinguish where shards go on the basis of them being primary or replica.

I realise that - if it is indeed possible to route shards on this basis - in the case of a failure, it's likely that a primary may have to go to a SSD host and/or a replica may have to go to a spinning disk host, and therefore maybe this is not possible at all. But any ideas welcomed.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [January 15, 2018, 2:04am UTC](https://discuss.elastic.co/t/can-you-force-primary-shards-to-only-be-on-certain-nodes-and-replica-shards-on-other-nodes/115465/2 "2018-01-15T02:04:50Z")

</div>

> [@ankh](#):
>
> How can we force primary shards to only be on the hosts with spinning disks, and replica shards to only be on hosts with SSDs?

You cannot do that because Elasticsearch doesn't differentiate between the two when it comes to allocation.

---

<div class="post-metadata">

**Author:** ![ankh](https://avatars.discourse-cdn.com/v4/letter/a/ea5d25/32.png) [@ankh](https://discuss.elastic.co/u/ankh)\
**Post date:** [January 16, 2018, 12:50am UTC](https://discuss.elastic.co/t/can-you-force-primary-shards-to-only-be-on-certain-nodes-and-replica-shards-on-other-nodes/115465/3 "2018-01-16T00:50:40Z")

</div>

Thanks for the reply Mark.

I guess we will have to rely on search preferences (eg, \_prefer\_nodes:xxx) to direct queries to the SSD nodes, and use shard allocation awareness to distinguish the spinning disk nodes from the SSD nodes, so the SSD nodes always have a complete copy of the index (albeit made up of both primary and replica shards).

Would that work? Are there any other options we can look at?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [January 16, 2018, 12:52am UTC](https://discuss.elastic.co/t/can-you-force-primary-shards-to-only-be-on-certain-nodes-and-replica-shards-on-other-nodes/115465/4 "2018-01-16T00:52:10Z")

</div>

> [@ankh](#):
>
> Would that work?

Yes.

> [@ankh](#):
>
> Are there any other options we can look at?

Use SSDs on both 😉

---

<div class="post-metadata">

**Author:** ![ankh](https://avatars.discourse-cdn.com/v4/letter/a/ea5d25/32.png) [@ankh](https://discuss.elastic.co/u/ankh)\
**Post date:** [January 16, 2018, 4:30am UTC](https://discuss.elastic.co/t/can-you-force-primary-shards-to-only-be-on-certain-nodes-and-replica-shards-on-other-nodes/115465/5 "2018-01-16T04:30:38Z")

</div>

Thanks Mark. Maybe SSDs can be the new swag at the next Sydney meetup! 😄

---

<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:** [February 13, 2018, 4:30am UTC](https://discuss.elastic.co/t/can-you-force-primary-shards-to-only-be-on-certain-nodes-and-replica-shards-on-other-nodes/115465/6 "2018-02-13T04:30:50Z")

</div>

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