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

gRPC APIs

원문 보기 위키 갱신

OpenSearch 3.2 버전부터 gRPC Bulk API와 k-NN 검색 쿼리가 일반 공개(GA)되었어요. 이 기능들은 protobuf 1.2.0 버전을 사용해요. 다만 앞으로의 버전에서 기능이 성숙해지면서 protobuf 구조에 업데이트가 있을 수 있으니 유의하세요. 기타 gRPC 검색 기능은 여전히 실험적이며 프로덕션에서 사용하는 것을 권장하지 않아요. 이 기능들의 진행 상황을 확인하거나 피드백을 남기려면 관련 GitHub 이슈를 참고하세요.

OpenSearch gRPC 기능은 gRPC를 사용해 OpenSearch와 통신하는 대안적이고 고성능인 전송 계층을 제공해요. gRPC 위에서 프로토콜 버퍼를 사용해 오버헤드를 낮추고 직렬화를 빠르게 해요. 초기 벤치마킹 결과에 따르면 이는 오버헤드를 줄이고 직렬화 속도를 높이며 요청 측 대기 시간을 개선해요. 자세한 내용은 Performance Benefits를 참고하세요.

출처: OpenSearch 문서

본문

지원되는 API (Supported APIs)

현재 지원되는 gRPC API는 다음과 같아요.

  • Bulk 일반 공개 3.2
  • k-NN 일반 공개 3.2
  • Search (선택된 쿼리 유형에 대해)
  • Predict Model Stream
  • Execute Agent Stream

gRPC API 사용 방법 (How to use gRPC APIs)

gRPC API를 사용하려면 다음 단계를 따라요.

  • 필요한 gRPC 설정을 구성해 gRPC 전송을 활성화해요.
  • gRPC 요청을 보내려면 클라이언트 쪽에 protobuf 모음이 있어야 해요. protobuf는 다음 방법으로 얻을 수 있어요.

| Language | Distribution method | Instructions | | Java | Maven Central repository | Download the opensearch-protobufs jar from the Maven Central repository. | | Python | PyPI repository | Download the opensearch-protobufs package from the PyPI repository. | | Other languages | GitHub repository (raw protobufs) | Download the raw protobuf schema from the OpenSearch Protobufs GitHub repository (v1.2.0). You can then generate client-side code using the protocol buffer compilers for the supported languages. |

gRPC 설정 (gRPC settings)

transport-grpc 모듈은 OpenSearch 설치에 기본으로 포함돼요. 이를 활성화하려면 opensearch.yml에 다음 설정을 추가하세요.

aux.transport.types: [transport-grpc]
aux.transport.transport-grpc.port: '9400-9500' // optional

또는 다음 설정을 사용해 보안 전송 프로토콜을 구성할 수 있어요.

aux.transport.types: [secure-transport-grpc]
aux.transport.transport-grpc.port: '9400-9500' // optional

필요하면 추가 설정을 구성해요 (자세한 내용은 Advanced gRPC settings 참고).

grpc.host: localhost
grpc.publish_host: 10.74.124.163
grpc.bind_host: 0.0.0.0

고급 gRPC 설정 (Advanced gRPC settings)

OpenSearch는 gRPC 통신을 위해 다음과 같은 고급 설정을 지원해요. 이 설정은 opensearch.yml에서 구성할 수 있어요.

| Setting name | Description | Example value | Default value | | grpc.publish_port | The external port number that this node uses to publish itself to peers for gRPC transport. | 9400 | -1 (disabled) | | grpc.host | A list of addresses the gRPC server will bind to. | ["0.0.0.0"] | [] | | grpc.bind_host | A list of addresses to bind the gRPC server to. Can be distinct from publish hosts. | ["0.0.0.0", "::"] | Value of grpc.host | | grpc.publish_host | A list of hostnames or IPs published to peers for client connections. | ["thisnode.example.com"] | Value of grpc.host | | grpc.netty.worker_count | The number of Netty worker threads for the gRPC server. Controls concurrency and parallelism. | 2 | Number of processors | | grpc.netty.executor_count | The number of threads in the fork-join pool for processing gRPC service calls. Controls request processing parallelism. | 32 | 2 * number of processors | | grpc.netty.max_concurrent_connection_calls | The maximum number of simultaneous in-flight requests allowed per client connection. | 200 | 100 | | grpc.netty.max_connection_age | The maximum age a connection can reach before being gracefully closed. Supports time units like ms, s, or m. See Time units. | 500ms | Not set (no limit) | | grpc.netty.max_connection_idle | The maximum duration for which a connection can be idle before being closed. Supports time units like ms, s, or m. See Time units. | 2m | Not set (no limit) | | grpc.netty.keepalive_timeout | The amount of time to wait for keepalive ping acknowledgment before closing the connection. Supports time units. | 1s | Not set | | grpc.netty.max_msg_size | The maximum inbound message size for gRPC requests. Supports units like b, kb, mb, or gb. See Supported units. | 10mb or 10485760 | 10mb |

예제 구성 (Example configuration)

다음은 opensearch.yml의 gRPC 전체 구성 예제예요.

# Basic gRPC transport configuration
aux.transport.types: [transport-grpc]
aux.transport.transport-grpc.port: '9400-9500'

# Advanced gRPC settings
grpc.host: ["0.0.0.0"]
grpc.bind_host: ["0.0.0.0", "::"]
grpc.publish_host: ["thisnode.example.com"]
grpc.publish_port: 9400
grpc.netty.worker_count: 4
grpc.netty.max_concurrent_connection_calls: 200
grpc.netty.max_connection_age: 500ms
grpc.netty.max_connection_idle: 2m
grpc.netty.keepalive_timeout: 1s
grpc.netty.max_msg_size: 10mb

이 설정들은 HTTP Network settings와 비슷하지만 gRPC 통신에 구체적으로 적용돼요.

gRPC 성능 이점 (gRPC performance benefits)

gRPC API를 사용하면 HTTP API에 비해 몇 가지 장점이 있어요.

  • 지연 시간 감소: 이진 프로토콜 버퍼가 JSON 파싱 오버헤드를 제거해요.
  • 더 높은 처리량: 빈도가 높은 쿼리에서 더 효율적인 네트워크 활용을 가능하게 해요.
  • 더 낮은 CPU 사용량: 직렬화·역직렬화 비용이 줄어들어요.
  • 타입 안전성: 프로토콜 버퍼 스키마가 컴파일 타임 검증을 제공해요.
  • 더 작은 페이로드 크기: 이진 인코딩이 네트워크 트래픽을 줄여요.

추가 성능 팁 (Additional performance tip)

SMILE 같은 지원되는 이진 포맷으로 문서를 인덱싱하면 JSON으로 인덱싱·검색하는 것보다 대개 더 낮은 지연 시간이 발생해요. 인덱싱과 검색 지연 시간이 모두 줄어들어야 해요.

더 알아보기 (Learn more)