사용자 도구

사이트 도구


search:elasticsearch

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
다음 판 양쪽 다음 판
search:elasticsearch [2019/01/10 15:50]
kwon37xi [Docker로 띄우면서 Clustering 할 때]
search:elasticsearch [2019/05/07 13:49]
kwon37xi
줄 14: 줄 14:
  
 ===== Sharding Routing ===== ===== Sharding Routing =====
 +  * 만약 Search 를 명확히 특정 Shard 단위로 할 수 있다면 샤딩을 촘촘히 해도 읽기/쓰기 성능이 모두 좋지만 
 +  * Sharding 기준이 명확하지 않아서 여러 Shard 에 걸쳐 Search 를 해야한다면, Shard 를 늘릴 수록 
 +    * 읽기 성능은 저하된다.
 +    * Write Primary 노드는 여러개로 분산 되므로 Write 성능은 높아진다.
 ==== Routing 강제 ==== ==== Routing 강제 ====
 라우팅을 강제할 수 있다. 라우팅 옵션 없이는 인덱싱 불가. 라우팅을 강제할 수 있다. 라우팅 옵션 없이는 인덱싱 불가.
줄 29: 줄 33:
   * ''host:9200/_cluster/settings?pretty'' : Cluster 상태 조회   * ''host:9200/_cluster/settings?pretty'' : Cluster 상태 조회
   * ''host:9200/_cluster/health?pretty'' : Cluster health check [[https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html|Cluster Health]]   * ''host:9200/_cluster/health?pretty'' : Cluster health check [[https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html|Cluster Health]]
 +
 ===== Docker로 띄우면서 Clustering 할 때 ===== ===== Docker로 띄우면서 Clustering 할 때 =====
   * [[:docker|Docker]]로 ES를 띄울 경우 ''network'' 설정이 복잡해진다.   * [[:docker|Docker]]로 ES를 띄울 경우 ''network'' 설정이 복잡해진다.
줄 69: 줄 74:
 <code sh> <code sh>
 --cap-add=SYS_PTRACE --cap-add=SYS_PTRACE
 +</code>
 +
 +===== Linux 설정 =====
 +  * [[https://www.elastic.co/guide/en/elasticsearch/reference/current/vm-max-map-count.html|Virtual memory | Elasticsearch Reference]]
 +<code>
 +sysctl -w vm.max_map_count=262144
 </code> </code>
  
줄 80: 줄 91:
  
 ===== 최적화 ===== ===== 최적화 =====
 +  * [[https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-replication.html|Reading and Writing documents]]
   * ''index.refresh_interval: 시간s'' : 인덱스를 push 하는 시간이라고 보면 되는데 ''5s'' 형태로 준다. 길수록 CPU 점유율은 떨어지지만 검색에 안나오는 시간도 길어진다.   * ''index.refresh_interval: 시간s'' : 인덱스를 push 하는 시간이라고 보면 되는데 ''5s'' 형태로 준다. 길수록 CPU 점유율은 떨어지지만 검색에 안나오는 시간도 길어진다.
   * ''bootstrap.mlockall: true'' : Linux 등에서 ES의 메모리를 swapping 하지 않게 설정 등.   * ''bootstrap.mlockall: true'' : Linux 등에서 ES의 메모리를 swapping 하지 않게 설정 등.
줄 86: 줄 98:
     * 메모리는 31GB 혹은 32bit Pointer가 될수 있는 max 값.     * 메모리는 31GB 혹은 32bit Pointer가 될수 있는 max 값.
     * Shard 는 최대 30GB가 될 정도 수준으로 구성.(Replica 도 계산시 단일 Shard로 쳐서)     * Shard 는 최대 30GB가 될 정도 수준으로 구성.(Replica 도 계산시 단일 Shard로 쳐서)
 +    * [[https://www.elastic.co/guide/en/elasticsearch/reference/current/tune-for-search-speed.html|Tune for search speed]]
 +
 +===== Write Performance =====
 +  * Sharding 을 하지 않을 경우 모든 Write 요청이 하나의 Primary Data Node로 집중된다.
 +  * Sharding 을 하면 각 Shard 별 Data Node로 분할 된다.
 +  * Write Thread 는 CPU 갯수만큼 생성된다. 그리고 Queue가 200개 할당된다.
 +  * Qeueue 갯수를 넘는 Write/Update 요청이 들어오면 reject 오류가 발생한다.
 +  * Write Thread 를 늘리고자 한다면 Scale Up 해서 CPU 갯수를 늘린다. Queue 갯수를 늘리는 것은 미봉책이므로 하지 않는 것이 좋다.
 +  * [[https://www.elastic.co/guide/en/elasticsearch/reference/current/tune-for-indexing-speed.html|Tune for indexing speed]]
 +  * [[https://www.elastic.co/kr/blog/why-am-i-seeing-bulk-rejections-in-my-elasticsearch-cluster|Why am I seeing bulk rejections in my Elasticsearch cluster?]]
 +  * [[https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-threadpool.html|Thread Pool]]
 +  * [[https://www.datadoghq.com/blog/elasticsearch-performance-scaling-problems/|How to solve 5 Elasticsearch performance and scaling problems]]
 +  * [[https://brunch.co.kr/@alden/36|rejected exception의 의미와 조치 방법]]
 +  * ''cat threadpool''<code>
 +GET /_cat/thread_pool
 +</code>
 +
 +===== G1 GC =====
 +  * G1 GC로 가려면 [[search:lucene|Lucene]] 관련 버그들이 해결된 [[java:10|Java 10]] 이상 버전 권장.
 +  * [[https://brunch.co.kr/@alden/45|G1 GC 적용과 JVM Upgrade]]
 +  * [[https://medium.com/naukri-engineering/garbage-collection-in-elasticsearch-and-the-g1gc-16b79a447181|Garbage Collection in Elasticsearch and the G1GC – Naukri Engineering – Medium]]
 +  * [[https://sematext.com/blog/java-9-elasticsearch-benchmark/|Java 9 Elasticsearch Benchmark: upgrading benefits]]
 +
 +===== Disk Size =====
 +  * [[https://www.elastic.co/guide/en/elasticsearch/reference/current/tune-for-disk-usage.html|Tune for disk usage ]]
 +
  
 ===== RollingFileAppender로 변경 ===== ===== RollingFileAppender로 변경 =====
줄 105: 줄 143:
   * 한 번 Version Upgrade 한 뒤 indexing을 하면 다시 Downgrade 할 수 없다. index를 백업 한 뒤에 업그레이드하라.   * 한 번 Version Upgrade 한 뒤 indexing을 하면 다시 Downgrade 할 수 없다. index를 백업 한 뒤에 업그레이드하라.
   * 2.x 버전에서 Tokenizer Plugin 을 사용할 때, 기본 Tokenizer type 이름과 tokenizer 이름이 다를경우 해당 토크나이저의 설정 정보가 처음에는 올바른 상태로 그리고 다시 한 번은 null 인 상태로 ''XxxTokenizerFactory'' 생성자가 한 번 더 호출되는 문제가 있다. 이에 따라 type 이름과 토크나이저 이름을 동일하게 맞춰줘야 했다. 이 경우 생성자가 인덱스당 한 번씩만 호출되었다.   * 2.x 버전에서 Tokenizer Plugin 을 사용할 때, 기본 Tokenizer type 이름과 tokenizer 이름이 다를경우 해당 토크나이저의 설정 정보가 처음에는 올바른 상태로 그리고 다시 한 번은 null 인 상태로 ''XxxTokenizerFactory'' 생성자가 한 번 더 호출되는 문제가 있다. 이에 따라 type 이름과 토크나이저 이름을 동일하게 맞춰줘야 했다. 이 경우 생성자가 인덱스당 한 번씩만 호출되었다.
 +
 ===== 참조 ===== ===== 참조 =====
   * [[http://blog.trifork.com/2013/10/24/how-to-avoid-the-split-brain-problem-in-elasticsearch/|How to avoid the split-brain problem in elasticsearch]]   * [[http://blog.trifork.com/2013/10/24/how-to-avoid-the-split-brain-problem-in-elasticsearch/|How to avoid the split-brain problem in elasticsearch]]
search/elasticsearch.txt · 마지막으로 수정됨: 2023/04/29 14:03 저자 kwon37xi