# Set primary shards location

**URL:** <https://discuss.elastic.co/t/set-primary-shards-location/34904>\
**Category:** Elasticsearch\
**Created:** [November 18, 2015, 9:22am UTC](https://discuss.elastic.co/t/set-primary-shards-location/34904 "2015-11-18T09:22:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![israel](https://avatars.discourse-cdn.com/v4/letter/i/b77776/32.png) [@israel](https://discuss.elastic.co/u/israel)\
**Post date:** [November 18, 2015, 9:22am UTC](https://discuss.elastic.co/t/set-primary-shards-location/34904/1 "2015-11-18T09:22:43Z")

</div>

Hi,

I have 10 machines and configured 10 shards (2 replicas for each). Is there a way for me to set that Shard 1 primary will reside on machine 1, Shard 2 primary will reside on machine 2 and so on...?

Thanks,

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 18, 2015, 9:37am UTC](https://discuss.elastic.co/t/set-primary-shards-location/34904/2 "2015-11-18T09:37:16Z")

</div>

Not really. But why do you want that?

If you have 10 nodes and 10 shards in total, you will end up with one shard per node.

---

<div class="post-metadata">

**Author:** ![israel](https://avatars.discourse-cdn.com/v4/letter/i/b77776/32.png) [@israel](https://discuss.elastic.co/u/israel)\
**Post date:** [November 18, 2015, 9:45am UTC](https://discuss.elastic.co/t/set-primary-shards-location/34904/3 "2015-11-18T09:45:17Z")

</div>

I need this to improve indexing time. I can route relevant data to a local indexer process running on the same machine.  
I could disable balancing, route each primary to its desired place, but then I am loosing the auto balancing. Also needs maintenance while new indexes are created....

---

<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 18, 2015, 9:53am UTC](https://discuss.elastic.co/t/set-primary-shards-location/34904/4 "2015-11-18T09:53:10Z")

</div>

The best way to improve indexing performance is to use the \_bulk API. As the documents in a single bulk request can belong to different shards, it is best to treat the cluster as a black box and let Elasticsearch manage distribution of data. Have you looked at the available documentation regarding [indexing performance tips](https://www.elastic.co/guide/en/elasticsearch/guide/current/indexing-performance.html?q=indexing) and [performance considerations for Elasticsearch indexing](https://www.elastic.co/blog/performance-considerations-elasticsearch-indexing?q=index%20performance)?

---

<div class="post-metadata">

**Author:** ![israel](https://avatars.discourse-cdn.com/v4/letter/i/b77776/32.png) [@israel](https://discuss.elastic.co/u/israel)\
**Post date:** [November 18, 2015, 11:14am UTC](https://discuss.elastic.co/t/set-primary-shards-location/34904/5 "2015-11-18T11:14:34Z")

</div>

I am using bulk API. This is to improve the performance more.  
For example, we have an API in our app to scroll all data. Instead of having one request scrolling on ES, I have created parallel scroll streams for each primary shard. This gave as a huge boost in throughput.

---

<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, 11:37pm UTC](https://discuss.elastic.co/t/set-primary-shards-location/34904/6 "2017-07-05T23:37:41Z")

</div>


