# Elasticsearch disk based shard allocation tuning

**URL:** https://discuss.elastic.co/t/elasticsearch-disk-based-shard-allocation-tuning/293616
**Category:** Elasticsearch
**Created:** [January 6, 2022, 5:39am UTC](https://discuss.elastic.co/t/elasticsearch-disk-based-shard-allocation-tuning/293616 "2022-01-06T05:39:39Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![tarund](https://avatars.discourse-cdn.com/v4/letter/t/977dab/32.png) [@tarund](https://discuss.elastic.co/u/tarund)
#### Post date: [January 6, 2022, 5:39am UTC](https://discuss.elastic.co/t/elasticsearch-disk-based-shard-allocation-tuning/293616/1 "2022-01-06T05:39:39Z")

</div>

I am running 2 node Elasticsearch cluster v7.9.2  
Ingesting data through APM-Server v7.15.0, creates ~50 new indices daily with pattern  
apm-7.15.0-\<service.name\>-transaction-YYYY.MM.DD

Observing that all new primary shards of new indices are getting created on 1 node, even though the free disk space % is lesser than the other node.  
How do I make the allocation of shards equally on both nodes ?  
How can I assign the allocation for a certain index pattern on a particular node.

Below is the cluster setting

```auto
"persistent" : {
    "cluster" : {
      "routing" : {
        "rebalance" : {
          "enable" : "primaries"
        },
        "allocation" : {
          "node_concurrent_incoming_recoveries" : "5",
          "node_concurrent_recoveries" : "5",
          "disk" : {
            "watermark" : {
              "low" : "75%",
              "flood_stage" : "90%",
              "high" : "80%"
            }
          },
          "enable" : "primaries"
        }
      },
      "max_shards_per_node" : "3000"
    },
    "xpack" : {
      "monitoring" : {
        "collection" : {
          "enabled" : "true"
        }
      }
    }

```

---

<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 9, 2022, 10:11pm UTC](https://discuss.elastic.co/t/elasticsearch-disk-based-shard-allocation-tuning/293616/2 "2022-01-09T22:11:31Z")

</div>

Allocation is based on shard count, then total disk use as a percentage.  
So what does `_cat/allocation?v` show?

> [@tarund](#):
>
> Elasticsearch cluster v7.9.2

You should really be running a newer version of Elasticsearch with APM at 7.15, ideally, the same versions.

> [@tarund](#):
>
> `"max_shards_per_node" : "3000"`

That's likely to cause you issues.

---

<div class="post-metadata">

### Author: ![tarund](https://avatars.discourse-cdn.com/v4/letter/t/977dab/32.png) [@tarund](https://discuss.elastic.co/u/tarund)
#### Post date: [January 12, 2022, 11:39am UTC](https://discuss.elastic.co/t/elasticsearch-disk-based-shard-allocation-tuning/293616/3 "2022-01-12T11:39:17Z")

</div>

Hi @warkolm , output for \_cat/allocation?v is as below

```auto
shards disk.indices disk.used disk.avail disk.total disk.percent host ip node
   208 1.4tb 1.6tb 1tb 2.6tb 59 2.12.27.1 2.12.27.1 node1
   185 515gb 772.8gb 602.1gb 1.3tb 56 2.12.25.2 2.12.25.2 node2

```

if allocation is based on shard count, then in above case, if 50 new indices are created ;would all new shards get allocated to just one node ?

I have also tried the below settings in index template, and changed the weight setting in cluster - "cluster.routing.allocation.balance.index": "20.0"(tried value as 1,10,20)

```auto
    "number_of_routing_shards": "4",
    "number_of_shards": "2",
    "number_of_replicas": "0"

```

but still both shards of same index are allocated on same node. Can you help me resolve this so that I have 2 shards per index on separate nodes.

---

<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 12, 2022, 7:00pm UTC](https://discuss.elastic.co/t/elasticsearch-disk-based-shard-allocation-tuning/293616/4 "2022-01-12T19:00:43Z")

</div>

> [@tarund](#):
>
> Can you help me resolve this so that I have 2 shards per index on separate nodes.

You probably want to look at using this, rather than altering cluster settings - [Cluster-level shard allocation and routing settings | Elasticsearch Guide [7.16] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/7.16/modules-cluster.html#shard-allocation-awareness)

---

<div class="post-metadata">

### Author: ![tarund](https://avatars.discourse-cdn.com/v4/letter/t/977dab/32.png) [@tarund](https://discuss.elastic.co/u/tarund)
#### Post date: [January 21, 2022, 5:38am UTC](https://discuss.elastic.co/t/elasticsearch-disk-based-shard-allocation-tuning/293616/5 "2022-01-21T05:38:50Z")

</div>

Thanks @warkolm . awareness attribute worked for me.

---

<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 18, 2022, 5:38am UTC](https://discuss.elastic.co/t/elasticsearch-disk-based-shard-allocation-tuning/293616/6 "2022-02-18T05:38:55Z")

</div>

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