2.X/6. Modeling Your Data

6-4-02. Shard Overallocation

drscg 2017. 9. 23. 13:03

A shard lives on a single node, but a node can hold multiple shards. Imagine that we created our index with two primary shards instead of one:

shard는 단일 node에 존재하지만, node는 여러 개의 shard를 가질 수 있다. 하나가 아닌 두 개의 primary shard를 가진, index를 생성했다고 가정해 보자.

PUT /my_index
{
  "settings": {
    "number_of_shards":   2, 
    "number_of_replicas": 0
  }
}

replica shard 없이, 두 개의 primary shard를 가진 index를 생성

With a single node, both shards would be assigned to the same node. From the point of view of our application, everything functions as it did before. The application communicates with the index, not the shards, and there is still only one index.

단일 node에서는, 두 개의 shard 모두는 동일한 node에 할당된다. 응용프로그램 입장에서 보면, 모든 기능은 전과 같다. 응용프로그램은 shard가 아닌, index와 통신하는데, 여전히 단 하나의 index만 있다.

This time, when we add a second node, Elasticsearch will automatically move one shard from the first node to the second node, as depicted in Figure 50, “두 개의 shard를 가진 index는 두 번째 node를 활용할 수 있다”. Once the relocation has finished, each shard will have access to twice the computing power that it had before.

이 때, 두 번째 node를 추가하면, Figure 50, “두 개의 shard를 가진 index는 두 번째 node를 활용할 수 있다” 처럼, Elasticsearch는 자동으로 첫 번째 node에 있는 어떤 shard를 두 번째 node로 옮긴다. 일단, 재할당이 완료되면, 각 shard는 기존에 비해, 두 배의 계산 능력을 가지게 된다.

Figure 50. 두 개의 shard를 가진 index는 두 번째 node를 활용할 수 있다

두 개의 shard를 가진 index는 두 번째 node를 활용할 수 있다


We have been able to double our capacity by simply copying a shard across the network to the new node. The best part is, we achieved this with zero downtime. All indexing and search requests continued to function normally while the shard was being moved.

네트워크를 통해, 단순히 특정 shard를 새로운 node로 복사하여, 능력을 두 배로 할 수 있었다. 가장 멋진 부분은 무정지(zero downtime)가 달성되었다는 점이다. 모든 색인과 검색 request는, shard를 옮기는 동안에도, 정상적으로 동작한다.

A new index in Elasticsearch is allotted five primary shards by default. That means that we can spread that index out over a maximum of five nodes, with one shard on each node. That’s a lot of capacity, and it happens without you having to think about it at all!

Elasticsearch에서, 새로운 index는 기본적으로 5개의 primary shard가 할당된다. 즉, 각 node당 하나의 shard를 가진, 최대 5개의 node로 해당 index를 확장할 수 있다. 이것은 많은 용량을 가진다. 생각지도 않았던 일들이 벌어진다.


'2.X > 6. Modeling Your Data' 카테고리의 다른 글

6-4. Designing for Scale  (0) 2017.09.23
6-4-01. The Unit of Scale  (0) 2017.09.23
6-4-03. Kagillion Shards  (0) 2017.09.23
6-4-04. Capacity Planning  (0) 2017.09.23
6-4-05. Replica Shards  (0) 2017.09.23