Elasticsearch(엘라스틱서치)

[elasticsearch] circuit_breaking_exception 에러 처리

yong_zz 2022. 10. 25. 16:27

Elasticsearch 운영중 기억에 남는 오류를 기록해본다..

 

해당 에러는 요청 작업에 의해서 OutOfMemoryError가 발생되는 것을 방지 하기 위해 차단하는것을 말한다.

 

 

해결법

1. 힙메모리 올리기

elasticsearch/config/jvm.options

# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space

-Xms8g
-Xmx8g

서버 메모리의 여유가 있을 경우 힙메모리를 늘려서 해결 할 수 있다.

Elasticsearch에서는 최대 메모리 설정 수치는 32g이하 이고, 서버 메모리의 절반을 설정하는것을 권장하고 있다.

 

 

2. 메모리 임계치 올리기

https://www.elastic.co/guide/en/elasticsearch/reference/current/circuit-breaker.html

 

Circuit breaker settings | Elasticsearch Guide [8.4] | Elastic

Circuit breaker settingsedit Elasticsearch contains multiple circuit breakers used to prevent operations from causing an OutOfMemoryError. Each breaker specifies a limit for how much memory it can use. Additionally, there is a parent-level breaker that spe

www.elastic.co

위 Elasticsearch 공식 가이드를 확인 하여 메모리 임계치 올리기

 

3. 인덱스 최적화

forcemerge 

https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-forcemerge.html

 

Force merge API | Elasticsearch Guide [8.4] | Elastic

We recommend only force merging a read-only index (meaning the index is no longer receiving writes). When documents are updated or deleted, the old version is not immediately removed, but instead soft-deleted and marked with a "tombstone". These soft-delet

www.elastic.co

 

index document 삭제처리 시 실제 물리서버 내에서 삭제되는 것이 아니라 삭제 표시만 하고, 마찬가지로

수정 처리시 기존 document를 삭제 표시 후 새로운 데이터를 삽입하는 프로세스이다.

주기적으로 Elasticsearch 자체에서 삭제 표시된 데이터를 정리를 한다고 하지만 메모리가 부족 할 경우 forcemerge를 통하여 많은 여유공간을 확보 할 수 있다.

 

주의점이 있는데 forcemerge를 사용할 index는 더이상 쓰기 작업이 없는 인덱스에만 사용하는것을 권장하고 있다.

 

 

 

나의 환경에서는 색인 데이터를 월별로 저장하고 있기 때문에 오래된 인덱스를 전부 강제병합으로 처리하여 여유공간을 확보했다.