# How do I calculate the number of shards I should have?

**URL:** https://discuss.elastic.co/t/how-do-i-calculate-the-number-of-shards-i-should-have/287561
**Category:** Elasticsearch
**Created:** [October 25, 2021, 10:37am UTC](https://discuss.elastic.co/t/how-do-i-calculate-the-number-of-shards-i-should-have/287561 "2021-10-25T10:37:58Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![riahc3](https://avatars.discourse-cdn.com/v4/letter/r/d6d6ee/32.png) [@riahc3](https://discuss.elastic.co/u/riahc3)
#### Post date: [October 25, 2021, 10:37am UTC](https://discuss.elastic.co/t/how-do-i-calculate-the-number-of-shards-i-should-have/287561/1 "2021-10-25T10:37:58Z")

</div>

Hello

Following the advice given on this forum (thank you), I have been able to reduce from August to now, shard amount: From 4028 to 3317

That being said, I feel this is a high number.

There is a document that says how to calculate what the ideal size should be but I cant seem to find it and if I remember, its kind of a few years old (I might be mistaken)

Could someone help me calculate this?

Thank you

---

<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: [October 25, 2021, 11:37am UTC](https://discuss.elastic.co/t/how-do-i-calculate-the-number-of-shards-i-should-have/287561/2 "2021-10-25T11:37:43Z")

</div>

May I suggest you look at the following resource about sizing:

> **[Size your shards | Elasticsearch Guide \[7.15\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/size-your-shards.html)**

In short:

- Something like 20 to 50gb par shard
- 20 shards per gb of HEAP

---

<div class="post-metadata">

### Author: ![riahc3](https://avatars.discourse-cdn.com/v4/letter/r/d6d6ee/32.png) [@riahc3](https://discuss.elastic.co/u/riahc3)
#### Post date: [October 25, 2021, 12:12pm UTC](https://discuss.elastic.co/t/how-do-i-calculate-the-number-of-shards-i-should-have/287561/3 "2021-10-25T12:12:28Z")

</div>

Hello

I forgot to mention this is all running on one node.

I dont quite fully understand the article I think.....Il reread it.

> In short:
> 
> - Something like 20 to 50gb par shard
> - 20 shards per gb of HEAP

Since I changed over to monthly, my biggest index (1 shard) is 12Gb.

But my heap I think is 16GB so (16 \* 20 = 320), I still have to lower it.

---

<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: [October 25, 2021, 3:36pm UTC](https://discuss.elastic.co/t/how-do-i-calculate-the-number-of-shards-i-should-have/287561/4 "2021-10-25T15:36:24Z")

</div>

> [@riahc3](#):
>
> But my heap I think is 16GB so (16 \* 20 = 320), I still have to lower it.

You have to lower the number of shard indeed.  
And may be reindex old daily indices for example into monthly indices.

Better could be to use [https://www.elastic.co/guide/en/elasticsearch//reference/current/index-lifecycle-management.html](https://www.elastic.co/guide/en/elasticsearch//reference/current/index-lifecycle-management.html) and [https://www.elastic.co/guide/en/elasticsearch//reference/current/data-streams.html](https://www.elastic.co/guide/en/elasticsearch//reference/current/data-streams.html)

---

<div class="post-metadata">

### Author: ![riahc3](https://avatars.discourse-cdn.com/v4/letter/r/d6d6ee/32.png) [@riahc3](https://discuss.elastic.co/u/riahc3)
#### Post date: [October 26, 2021, 9:35am UTC](https://discuss.elastic.co/t/how-do-i-calculate-the-number-of-shards-i-should-have/287561/5 "2021-10-26T09:35:27Z")

</div>

I had daily indexes before and after 180 days, those dailies are being erased.

New logs are all monthly and thats why (I think) the shard amount is going down.

It will still take a while but they are indeed going down.

I actually use ILM for 180 days deletion.

Im not sure what data streams are exactly ; What are their pros and cons for logs that are constantly being sent and are time based?

---

<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: [October 26, 2021, 12:23pm UTC](https://discuss.elastic.co/t/how-do-i-calculate-the-number-of-shards-i-should-have/287561/6 "2021-10-26T12:23:50Z")

</div>

If your cluster (or node) is under pressure and you can't reindex, you can always start to remove manually the older indices without having to wait for 180 days.

---

<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 23, 2021, 12:23pm UTC](https://discuss.elastic.co/t/how-do-i-calculate-the-number-of-shards-i-should-have/287561/7 "2021-11-23T12:23:55Z")

</div>

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