# Relation between shards and nodes

**URL:** <https://discuss.elastic.co/t/relation-between-shards-and-nodes/104562>\
**Category:** Elasticsearch\
**Created:** [October 19, 2017, 1:38pm UTC](https://discuss.elastic.co/t/relation-between-shards-and-nodes/104562 "2017-10-19T13:38:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jessepeixoto](https://avatars.discourse-cdn.com/v4/letter/j/53a042/32.png) [@jessepeixoto](https://discuss.elastic.co/u/jessepeixoto)\
**Post date:** [October 19, 2017, 1:38pm UTC](https://discuss.elastic.co/t/relation-between-shards-and-nodes/104562/1 "2017-10-19T13:38:29Z")

</div>

Could anyone please tell me a little about the relation between shards and nodes.

If I have 30 nodes, I believe it won't work setting up more than 30 shards per index.

In the other hand, if I have 30 nodes, setting up only 5 shards would be a huge waste of nodes.

Am I right ?

Thanks in advance,

Jessé

---

<div class="post-metadata">

**Author:** ![A\_B](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/a_b/32/17104_2.png) [@A\_B](https://discuss.elastic.co/u/A_B)\
**Post date:** [October 20, 2017, 2:13pm UTC](https://discuss.elastic.co/t/relation-between-shards-and-nodes/104562/2 "2017-10-20T14:13:17Z")

</div>

How many indices will you have? And how many replicas do you plan to use per shard?

---

<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 20, 2017, 4:17pm UTC](https://discuss.elastic.co/t/relation-between-shards-and-nodes/104562/3 "2017-10-20T16:17:19Z")

</div>

Shards represents a subpart of an index. It's a group of documents that goes to a shard.  
A shard lives anywhere in the cluster and is allocated on a node.

An index is a group of shards. As a developer you index a document to an index but the document is routed to a shard where it gets stored and indexed.

You have primary shards and you may have replica shards. Replicas are perfect copies of primary shards.

A node is a JVM instance running elasticsearch.  
It can host multiple shards, coming from multiple indices.

Does this answer?

---

<div class="post-metadata">

**Author:** ![jessepeixoto](https://avatars.discourse-cdn.com/v4/letter/j/53a042/32.png) [@jessepeixoto](https://discuss.elastic.co/u/jessepeixoto)\
**Post date:** [October 25, 2017, 7:08pm UTC](https://discuss.elastic.co/t/relation-between-shards-and-nodes/104562/4 "2017-10-25T19:08:27Z")

</div>

Thank for replying @A_B and @dadoonet. I don't have any indices yet. I am just studying. At my studing I figured out that the amount of shards I will set must not be higher than the total of nodes I have, otherwise I would be wasting resources. Is that correct?

---

<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:** [October 25, 2017, 7:34pm UTC](https://discuss.elastic.co/t/relation-between-shards-and-nodes/104562/5 "2017-10-25T19:34:15Z")

</div>

It will depend on the use case. For some use cases, e.g. search use cases and high query throughput and a small data set, a single shard per node may be optimal, but most use cases have more than that. [This talk](https://www.elastic.co/elasticon/conf/2016/sf/quantitative-cluster-sizing) may give you a better idea about how to determine the ideal number of shards for your use case.

---

<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 22, 2017, 7:34pm UTC](https://discuss.elastic.co/t/relation-between-shards-and-nodes/104562/6 "2017-11-22T19:34:22Z")

</div>

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