# Optimal Number of Shards

**URL:** <https://discuss.elastic.co/t/optimal-number-of-shards/22438>\
**Category:** Elasticsearch\
**Created:** [February 27, 2015, 6:46pm UTC](https://discuss.elastic.co/t/optimal-number-of-shards/22438 "2015-02-27T18:46:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Gligorov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/daniel_gligorov/32/872_2.png) [@Daniel\_Gligorov](https://discuss.elastic.co/u/Daniel_Gligorov)\
**Post date:** [February 27, 2015, 6:46pm UTC](https://discuss.elastic.co/t/optimal-number-of-shards/22438/1 "2015-02-27T18:46:48Z")

</div>

Hi,

Lets say I have 100 node cluster, each with 16G heap (50% of the RAM). I  
have single index, its 1G, and I know it won't be growing much (will never  
grow above the heap size).

1. Is having single shard better than having 5 by default? Then to spread  
the load will run 99 replicas

2. If index size \< heap size, is all that heap memory wasted? I mean lets  
say I have 5G index, would it be better to have 4 nodes with 5G heap or 2  
with 10G heap?

Thank you,

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/be8255a3-28c3-4754-ac17-c94e2b16afaf%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/be8255a3-28c3-4754-ac17-c94e2b16afaf%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [February 27, 2015, 11:28pm UTC](https://discuss.elastic.co/t/optimal-number-of-shards/22438/2 "2015-02-27T23:28:30Z")

</div>

1GB is small, it's very easy to make it fit entirely in the filesystem  
cache. For this kind of small index where you want to optimize the search  
throughput, just have one shard per index and have it replicated once per  
node (option 1 that you described).

Regarding 2, indeed with such a small index you will probably not need 16GB  
per machine. Having several nodes per machine would not help since the  
bottleneck would be CPU (not disk since everything fits in the FS cache and  
not memory since you have much more memory than your index size) and a  
single node can already make use of all your CPUs.

For more general considerations about shard sizing, the following chapter  
of the reference guide gives practical advice around picking up the right  
shard size and number of shards:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

On Fri, Feb 27, 2015 at 7:46 PM, Daniel Gligorov [gligorov.daniel@gmail.com](mailto:gligorov.daniel@gmail.com)  
wrote:

> Hi,
> 
> Lets say I have 100 node cluster, each with 16G heap (50% of the RAM). I  
> have single index, its 1G, and I know it won't be growing much (will never  
> grow above the heap size).
> 
> 1. Is having single shard better than having 5 by default? Then to spread  
> the load will run 99 replicas
> 
> 2. If index size \< heap size, is all that heap memory wasted? I mean lets  
> say I have 5G index, would it be better to have 4 nodes with 5G heap or 2  
> with 10G heap?
> 
> Thank you,
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/be8255a3-28c3-4754-ac17-c94e2b16afaf%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/be8255a3-28c3-4754-ac17-c94e2b16afaf%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/be8255a3-28c3-4754-ac17-c94e2b16afaf%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/be8255a3-28c3-4754-ac17-c94e2b16afaf%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
Adrien Grand

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j6%3DtnJF8spx%3DvSxyNs0otrkNCp%3DhkgZxH4dkrF8MnLWNQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j6%3DtnJF8spx%3DvSxyNs0otrkNCp%3DhkgZxH4dkrF8MnLWNQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 12:29am UTC](https://discuss.elastic.co/t/optimal-number-of-shards/22438/3 "2017-07-06T00:29:21Z")

</div>


