본문 바로가기
WIKI 기술 지식 베이스

Performance Analyzer

원문 보기 위키 갱신

출처: 문서

본문

Performance Analyzer

Performance Analyzer는 에이전트와 REST API를 포함하는 플러그인으로, 이를 통해 클러스터 성능 지표와 그 지표들의 집계를 포함한 수많은 지표를 쿼리할 수 있어요.

Performance Analyzer 플러그인은 OpenSearch 2.0 이상 버전에 기본으로 설치되어 있어요. Performance Analyzer를 비활성화한 상태로 OpenSearch 2.0 이상을 사용하고 싶다면 Disable Performance Analyzer를 참고하세요. {: .note }

사전 준비 사항

OpenSearch와 함께 Performance Analyzer를 사용하기 전에 다음 사전 준비 사항을 확인하세요.

스토리지

Performance Analyzer는 임시 저장소로 /dev/shm을 사용해요. 클러스터에 무거운 워크로드가 몰리는 동안 Performance Analyzer는 최대 1 GB까지 공간을 사용할 수 있어요.

하지만 Docker의 기본 /dev/shm 크기는 64 MB예요. 이 값을 바꾸려면 docker run --shm-size 1gb 플래그나 Docker Compose의 유사한 설정을 사용할 수 있어요.

Docker를 사용하지 않는다면 df -h로 /dev/shm의 크기를 확인할 수 있어요. 기본값으로도 충분하지만, 크기를 바꿔야 한다면 /etc/fstab에 다음 줄을 추가하세요:

tmpfs /dev/shm tmpfs defaults,noexec,nosuid,size=1G 0 0

그다음 파일 시스템을 다시 마운트하세요:

mount -o remount /dev/shm

보안

Performance Analyzer는 요청에 대한 전송 중 암호화를 지원해요. 다만 요청에 대한 클라이언트 또는 서버 인증은 지원하지 않아요. 전송 중 암호화를 활성화하려면 $OPENSEARCH_HOME 디렉터리에 있는 performance-analyzer.properties를 편집하세요:

vi $OPENSEARCH_HOME/config/opensearch-performance-analyzer/performance-analyzer.properties

전송 중 암호화를 구성하려면 다음 줄들을 변경하세요. certificate-file-path는 루트 인증 기관(CA) 인증서가 아니라 서버용 인증서여야 한다는 점에 유의하세요.

https-enabled = true

#Setup the correct path for certificates
certificate-file-path = specify_path

private-key-file-path = specify_path

Performance Analyzer 설치

Performance Analyzer 플러그인은 Docker 및 tarball 설치에 포함되어 있지만, 플러그인을 수동으로 설치할 수도 있어요.

Performance Analyzer 플러그인을 수동으로 설치하려면 Maven에서 플러그인을 다운로드하고 표준 플러그인 설치 절차에 따라 설치하세요. Performance Analyzer는 클러스터의 각 노드에서 실행돼요.

tarball 설치에서 Performance Analyzer 근본 원인 분석(RCA) 에이전트를 시작하려면 다음 명령어를 실행하세요:

OPENSEARCH_HOME=~/opensearch-{{ site.opensearch_version }} OPENSEARCH_JAVA_HOME=~/opensearch-{{ site.opensearch_version }}/jdk OPENSEARCH_PATH_CONF=~/opensearch-{{ site.opensearch_version }}/bin ./performance-analyzer-agent-cli

다음 명령어는 Performance Analyzer 플러그인을 활성화해요.

curl -XPOST localhost:9200/_plugins/_performanceanalyzer/cluster/config -H 'Content-Type: application/json' -d '{"enabled": true}'

Performance Analyzer 비활성화

메모리를 절약하면서 Performance Analyzer 플러그인을 비활성화한 상태로 로컬 OpenSearch 인스턴스를 실행하고 싶다면 다음 단계를 수행하세요:

  1. Performance Analyzer를 비활성화하기 전에, 다음 명령어를 사용해 현재 실행 중인 RCA 에이전트 작업을 먼저 중지하세요:
curl -XPOST localhost:9200/_plugins/_performanceanalyzer/rca/cluster/config -H 'Content-Type: application/json' -d '{"enabled": false}'
  1. 다음 명령어를 실행해 Performance Analyzer RCA 에이전트를 종료하세요:
kill $(ps aux | grep -i 'PerformanceAnalyzerApp' | grep -v grep | awk '{print $2}')
  1. 다음 명령어를 실행해 Performance Analyzer 플러그인을 비활성화하세요:
curl -XPOST localhost:9200/_plugins/_performanceanalyzer/cluster/config -H 'Content-Type: application/json' -d '{"enabled": false}'
  1. 다음 명령어를 실행해 Performance Analyzer 플러그인을 제거하세요:
bin/opensearch-plugin remove opensearch-performance-analyzer

Performance Analyzer 구성

Performance Analyzer 플러그인을 구성하려면 config/opensearch-performance-analyzer/ 디렉터리의 performance-analyzer.properties 구성 파일을 편집하세요. #webservice-bind-host 줄의 주석을 해제하고 0.0.0.0으로 설정했는지 꼭 확인하세요. 다음 예시 구성을 참고할 수 있어요.

# ======================== OpenSearch Performance Analyzer plugin config =========================

# NOTE: this is an example for Linux. Please modify the config accordingly if you are using it under other OS.

# WebService bind host; default to all interfaces
webservice-bind-host = 0.0.0.0

# Metrics data location
metrics-location = /dev/shm/performanceanalyzer/

# Metrics deletion interval (minutes) for metrics data.
# Interval should be between 1 to 60.
metrics-deletion-interval = 1

# If set to true, the system cleans up the files behind it. So at any point, we should expect only 2
# metrics-db-file-prefix-path files. If set to false, no files are cleaned up. This can be useful, if you are archiving
# the files and wouldn't like for them to be cleaned up.
cleanup-metrics-db-files = true

# WebService exposed by App's port
webservice-listener-port = 9600

# Metric DB File Prefix Path location
metrics-db-file-prefix-path = /tmp/metricsdb_

https-enabled = false

#Setup the correct path for certificates
#certificate-file-path = specify_path

#private-key-file-path = specify_path

# Plugin Stats Metadata file name, expected to be in the same location
plugin-stats-metadata = plugin-stats-metadata

# Agent Stats Metadata file name, expected to be in the same location
agent-stats-metadata = agent-stats-metadata

Performance Analyzer RCA 에이전트를 시작하려면 다음 명령어를 실행하세요:

OPENSEARCH_HOME=~/opensearch-{{ site.opensearch_version }} OPENSEARCH_JAVA_HOME=~/opensearch-{{ site.opensearch_version }}/jdk OPENSEARCH_PATH_CONF=~/opensearch-{{ site.opensearch_version }}/bin ./performance-analyzer-agent-cli

RPM/YUM 설치에서 Performance Analyzer 활성화

RPM 배포판으로 OpenSearch를 설치했다면 systemctl로 Performance Analyzer를 시작하고 중지할 수 있어요:

# Start OpenSearch Performance Analyzer
sudo systemctl start opensearch-performance-analyzer.service
# Stop OpenSearch Performance Analyzer
sudo systemctl stop opensearch-performance-analyzer.service

API 쿼리 및 응답 예시

다음은 Performance Analyzer API 쿼리 예시예요. 이 쿼리는 OpenSearch 클러스터와 관련된 성능 지표를 가져와요:

GET localhost:9600/_plugins/_performanceanalyzer/metrics/units

다음은 응답 예시예요:

{"Disk_Utilization":"%","Cache_Request_Hit":"count", 
"Refresh_Time":"ms","ThreadPool_QueueLatency":"count",
"Merge_Time":"ms","ClusterApplierService_Latency":"ms",
"PublishClusterState_Latency":"ms",
"Cache_Request_Size":"B","LeaderCheck_Failure":"count",
"ThreadPool_QueueSize":"count","Sched_Runtime":"s/ctxswitch","Disk_ServiceRate":"MB/s","Heap_AllocRate":"B/s","Indexing_Pressure_Current_Limits":"B",
"Sched_Waittime":"s/ctxswitch","ShardBulkDocs":"count",
"Thread_Blocked_Time":"s/event","VersionMap_Memory":"B",
"Master_Task_Queue_Time":"ms","IO_TotThroughput":"B/s",
"Indexing_Pressure_Current_Bytes":"B",
"Indexing_Pressure_Last_Successful_Timestamp":"ms",
"Net_PacketRate6":"packets/s","Cache_Query_Hit":"count",
"IO_ReadSyscallRate":"count/s","Net_PacketRate4":"packets/s","Cache_Request_Miss":"count",
"ThreadPool_RejectedReqs":"count","Net_TCP_TxQ":"segments/flow","Master_Task_Run_Time":"ms",
"IO_WriteSyscallRate":"count/s","IO_WriteThroughput":"B/s",
"Refresh_Event":"count","Flush_Time":"ms","Heap_Init":"B",
"Indexing_Pressure_Rejection_Count":"count",
"CPU_Utilization":"cores","Cache_Query_Size":"B",
"Merge_Event":"count","Cache_FieldData_Eviction":"count",
"IO_TotalSyscallRate":"count/s","Net_Throughput":"B/s",
"Paging_RSS":"pages",
"AdmissionControl_ThresholdValue":"count",
"Indexing_Pressure_Average_Window_Throughput":"count/s",
"Cache_MaxSize":"B","IndexWriter_Memory":"B",
"Net_TCP_SSThresh":"B/flow","IO_ReadThroughput":"B/s",
"LeaderCheck_Latency":"ms","FollowerCheck_Failure":"count",
"HTTP_RequestDocs":"count","Net_TCP_Lost":"segments/flow",
"GC_Collection_Event":"count","Sched_CtxRate":"count/s",
"AdmissionControl_RejectionCount":"count","Heap_Max":"B",
"ClusterApplierService_Failure":"count",
"PublishClusterState_Failure":"count",
"Merge_CurrentEvent":"count","Indexing_Buffer":"B",
"Bitset_Memory":"B","Net_PacketDropRate4":"packets/s",
"Heap_Committed":"B","Net_PacketDropRate6":"packets/s",
"Thread_Blocked_Event":"count","GC_Collection_Time":"ms",
"Cache_Query_Miss":"count","Latency":"ms",
"Shard_State":"count","Thread_Waited_Event":"count",
"CB_ConfiguredSize":"B","ThreadPool_QueueCapacity":"count",
"CB_TrippedEvents":"count","Disk_WaitTime":"ms",
"Data_RetryingPendingTasksCount":"count",
"AdmissionControl_CurrentValue":"count",
"Flush_Event":"count","Net_TCP_RxQ":"segments/flow",
"Shard_Size_In_Bytes":"B","Thread_Waited_Time":"s/event",
"HTTP_TotalRequests":"count",
"ThreadPool_ActiveThreads":"count",
"Paging_MinfltRate":"count/s","Net_TCP_SendCWND":"B/flow",
"Cache_Request_Eviction":"count","Segments_Total":"count",
"FollowerCheck_Latency":"ms","Heap_Used":"B",
"Master_ThrottledPendingTasksCount":"count",
"CB_EstimatedSize":"B","Indexing_ThrottleTime":"ms",
"Master_PendingQueueSize":"count",
"Cache_FieldData_Size":"B","Paging_MajfltRate":"count/s",
"ThreadPool_TotalThreads":"count","ShardEvents":"count",
"Net_TCP_NumFlows":"count","Election_Term":"count"}

근본 원인 분석

근본 원인 분석(RCA) 프레임워크는 Performance Analyzer의 정보를 활용해 클러스터에서 겪는 성능 및 가용성 문제의 근본 원인을 관리자에게 알려줘요.

RCA 프레임워크 활성화

RCA 프레임워크를 활성화하려면 다음 명령어를 실행하세요:

curl -XPOST http://localhost:9200/_plugins/_performanceanalyzer/rca/cluster/config -H 'Content-Type: application/json' -d '{"enabled": true}'

curl: (52) Empty reply from server 응답이 표시되면 다음 명령어를 실행해 RCA를 활성화하세요:

curl -XPOST https://localhost:9200/_plugins/_performanceanalyzer/rca/cluster/config -H 'Content-Type: application/json' -d '{"enabled": true}' -u 'admin:<custom-admin-password>' -k

API 쿼리 및 응답 예시

사용 가능한 모든 RCA를 요청하려면 다음 명령어를 실행하세요:

GET localhost:9600/_plugins/_performanceanalyzer/rca

특정 RCA를 요청하려면 다음 명령어를 실행하세요:

GET localhost:9600/_plugins/_performanceanalyzer/rca?name=HighHeapUsageClusterRCA

다음은 응답 예시예요:

{
  "HighHeapUsageClusterRCA": [{
    "RCA_name": "HighHeapUsageClusterRCA",
    "state": "unhealthy",
    "timestamp": 1587426650942,
    "HotClusterSummary": [{
      "number_of_nodes": 2,
      "number_of_unhealthy_nodes": 1,
      "HotNodeSummary": [{
        "host_address": "192.168.144.2",
        "node_id": "JtlEoRowSI6iNpzpjlbp_Q",
        "HotResourceSummary": [{
          "resource_type": "old gen",
          "threshold": 0.65,
          "value": 0.81827232588145373,
          "avg": NaN,
          "max": NaN,
          "min": NaN,
          "unit_type": "heap usage in percentage",
          "time_period_seconds": 600,
          "TopConsumerSummary": [{
              "name": "CACHE_FIELDDATA_SIZE",
              "value": 590702564
            },
            {
              "name": "CACHE_REQUEST_SIZE",
              "value": 28375
            },
            {
              "name": "CACHE_QUERY_SIZE",
              "value": 12687
            }
          ],
        }]
      }]
    }]
  }]
}

관련 링크

Performance Analyzer와 RCA 사용에 대한 추가 문서는 다음 링크에서 확인할 수 있어요:

일반적인 문제

Performance Analyzer에서 Illegal reflective access operation 경고를 기록할 수 있어요. 이는 기능에는 영향을 주지 않는 알려진 문제예요.

더 알아보기 (Learn more)