# How is data within an index distributed into shards?

**URL:** https://discuss.elastic.co/t/how-is-data-within-an-index-distributed-into-shards/121670
**Category:** Elasticsearch
**Created:** [February 27, 2018, 2:02pm UTC](https://discuss.elastic.co/t/how-is-data-within-an-index-distributed-into-shards/121670 "2018-02-27T14:02:46Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Jan\_Pisl](https://avatars.discourse-cdn.com/v4/letter/j/858c86/32.png) [@Jan\_Pisl](https://discuss.elastic.co/u/Jan_Pisl)
#### Post date: [February 27, 2018, 2:02pm UTC](https://discuss.elastic.co/t/how-is-data-within-an-index-distributed-into-shards/121670/1 "2018-02-27T14:02:47Z")

</div>

I am new to ES and although I have read several blog posts and articles, I still cannot find the answers I am looking for. I need to ensure that shards in my ES database will have the optimal size (performance-wise).

I understand that the optimal size of a shard depends on multiple factors and that it (I suppose) can only be determined by tests with using real data.

What I don't understand is how data is distributed into shards within an index. For example, if there are five (primary) shards in an index and I set the maximal index size to 100 GB, will each shard be 20 GB when the index reaches its limit? So, if I find out the optimal shard size I can just multiply it by the number of shards in an index and use this value as the maximal index size? Or is it not this simple?

And more generally, why is it that there is no tool for simply specifying the maximal shard size instead of the maximal index size (such se the Rollover API) ?

---

<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: [February 27, 2018, 2:16pm UTC](https://discuss.elastic.co/t/how-is-data-within-an-index-distributed-into-shards/121670/2 "2018-02-27T14:16:42Z")

</div>

> and I set the maximal index size to 100 GB

No you never do that with elasticsearch. Sky is the limit 🙂

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

> **[Quantitative Cluster Sizing](https://www.elastic.co/elasticon/conf/2016/sf/quantitative-cluster-sizing)**

> **[How many shards should I have in my Elasticsearch cluster?](https://www.elastic.co/blog/how-many-shards-should-i-have-in-my-elasticsearch-cluster)**

> **[NetSecureDay: Managing your Black Friday Logs](https://speakerdeck.com/elastic/netsecureday-managing-your-black-friday-logs)**
>
> Surveiller une application complexe n’est pas une tâche aisée, mais avec les bons outils, ce n’est pas si sorcier. Néanmoins, des périodes fortes telles que les opérations de type « Black Friday » (Vendredi noir) ou période de Noël peuvent pousser...

[![](https://us1.discourse-cdn.com/elastic/original/3X/7/c/7c2edebd5bac194c58a5df87ede6872cb41d61a8.jpeg "Managing your Black Friday Logs, Pablo Musa, Elastic, TechSummit Amsterdam") ](https://www.youtube.com/watch?v=ilP7tG6tabI)

---

<div class="post-metadata">

### Author: ![Jan\_Pisl](https://avatars.discourse-cdn.com/v4/letter/j/858c86/32.png) [@Jan\_Pisl](https://discuss.elastic.co/u/Jan_Pisl)
#### Post date: [February 27, 2018, 2:29pm UTC](https://discuss.elastic.co/t/how-is-data-within-an-index-distributed-into-shards/121670/3 "2018-02-27T14:29:21Z")

</div>

Thank you for you response!

I will most certainly go through the recourses you suggested. However, I am a bit perplexed by you saying

> [@dadoonet](#):
>
> No you never do that with elasticsearch. Sky is the limit

because in the very article you recommend me (and that I have already read) "How many shards should I have in my Elasticsearch cluster?", they say that "a shard size of 50GB is often quoted as a limit that has been seen to work". So doesn't it make sense to limit the size of indices then (because they consist of shards)? Or how else do I control the size of shards? I feel like I am missing something here...

---

<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: [February 27, 2018, 2:46pm UTC](https://discuss.elastic.co/t/how-is-data-within-an-index-distributed-into-shards/121670/4 "2018-02-27T14:46:02Z")

</div>

Yes. That's a theorical limit. If you send more data, elasticsearch will still accept it and index it.  
So there is no "limit" as an index settings or something like this.  
I'd say that the only limit I know for now is the available disk space.

> So doesn't it make sense to limit the size of indices

yes. But elasticsearch does not have that built-in setting as I said.

> Or how else do I control the size of shards?

You can use the rollover API to achieve what you are looking for: keeping data under a given limit per shard.  
See [Rollover Index | Elasticsearch Reference [6.2] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/6.2/indices-rollover-index.html)

---

<div class="post-metadata">

### Author: ![Jan\_Pisl](https://avatars.discourse-cdn.com/v4/letter/j/858c86/32.png) [@Jan\_Pisl](https://discuss.elastic.co/u/Jan_Pisl)
#### Post date: [February 27, 2018, 3:00pm UTC](https://discuss.elastic.co/t/how-is-data-within-an-index-distributed-into-shards/121670/5 "2018-02-27T15:00:44Z")

</div>

Ok so just to clarify I am on the same page: the way to control shard size (keep data under a given limit per shard) is to control index size & number of shards per index. do you agree on that?

thank you very much your answers are very helpful to me! ☀

---

<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: [February 27, 2018, 6:35pm UTC](https://discuss.elastic.co/t/how-is-data-within-an-index-distributed-into-shards/121670/6 "2018-02-27T18:35:55Z")

</div>

I agree on that.

---

<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: [March 27, 2018, 6:35pm UTC](https://discuss.elastic.co/t/how-is-data-within-an-index-distributed-into-shards/121670/7 "2018-03-27T18:35:57Z")

</div>

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