Nidhi Gupta
3 min readApr 17, 2022

--

Primary shards & Replica shards in Elasticsearch

Shards offer the most competitive balance between allocation speed, node balancing, and overall cluster management.

In this article let’s understand the theoretical and practical concept of sharding in elastic search. Let’s understand first what sharding is, and how it proved to be an advantage or disadvantage in databases.

If we talk about the architecture of elastic search or how data is added or written to the index and how data gets added to shards. So, here data is first written in documents using JSON structure in indexes. These documents are written to nodes as indexes than to different shards and each shard has its replica to recover data in case of node failure. The primary shard and replica shard are always placed on different nodes.

Earlier versions of elastic search had by default 5 primary shards and 5 replica shards. As per the latest ELK version we have 1 primary shard and 1 replica shard. Whenever we start writing data to indexes it is necessary to know the number of shards and number of replicas per shard in elastic search. Horizontal scaling or scale-out is the main reason to share a database. The number of shards depends heavily on the amount of data we have.

Note: We can change a number of shards without losing our data. However this process will require a brief

--

--

Nidhi Gupta
Nidhi Gupta

Written by Nidhi Gupta

Azure Data Engineer 👨‍💻.Heading towards cloud technologies expertise✌️.

Responses (2)