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

Azure Storage Queue 스케일러

원문 보기 위키 갱신

Azure Storage Queue에 쌓인 메시지 개수에 따라 워크로드를 자동으로 늘리고 줄이고 싶을 때 사용하는 스케일러예요. 메시지가 많아지면 파드를 늘리고, 처리되면 다시 줄이는 원리를 살펴볼게요.

출처: 문서

본문

트리거 명세 (Trigger Specification)

이 명세는 Azure Storage Queue를 위한 azure-queue 트리거를 설명해요.

triggers:
- type: azure-queue
  metadata:
    queueName: orders
    queueLength: '5'
    queueLengthStrategy: all|visibleonly
    activationQueueLength: '50'
    connectionFromEnv: STORAGE_CONNECTIONSTRING_ENV_NAME
    accountName: storage-account-name
    cloud: AzureUSGovernmentCloud

파라미터 목록:

  • queueName - 큐의 이름이에요.
  • queueLength - 스케일러에 전달하는 큐 길이의 목표 값이에요. 예를 들어 파드 하나가 메시지 10개를 처리할 수 있다면 큐 길이 목표를 10으로 설정해요. 실제 큐에 메시지가 30개 있다면 스케일러는 파드를 3개로 늘려요. (기본값: 5, 선택 사항)
  • queueLengthStrategy - all은 보이는 메시지와 보이지 않는 메시지를 모두 고려하고, visibleonly는 Peek를 사용해 보이는 메시지만 세요. visibleonly에서는 메시지 수가 32개 이상이면 기본 all 전략으로 돌아가 보이는 메시지와 보이지 않는 메시지를 모두 세요. (기본값: all, 선택 사항)
  • activationQueueLength - 스케일러를 활성화하는 목표 값이에요. 활성화(activation)에 대해 더 알고 싶다면 여기를 참고해요. (기본값: 0, 선택 사항)
  • connectionFromEnv - 배포가 연결 문자열을 가져올 때 사용하는 환경 변수의 이름이에요.
  • accountName - 큐가 속한 스토리지 계정의 이름이에요.
  • cloud - 큐가 속한 클라우드 환경의 이름이에요. 알려진 Azure 클라우드 환경이거나, Azure Stack Hub 또는 Air Gapped 클라우드에서는 Private이어야 해요. (유효한 값: AzurePublicCloud, AzureUSGovernmentCloud, AzureChinaCloud, AzureGermanCloud, Private; 기본값: AzurePublicCloud)

cloud가 Private로 설정되면 endpointSuffix 파라미터가 필수예요. 그 외에는 클라우드 환경에 따라 자동으로 생성돼요. endpointSuffix는 큐가 속한 클라우드 환경의 스토리지 큐 엔드포인트 접미사를 나타내는데, 예를 들어 AzurePublicCloud의 경우 queue.core.windows.net이에요.

인증 파라미터 (Authentication Parameters)

pod identity나 연결 문자열 인증을 사용해 인증할 수 있어요.

연결 문자열 인증(Connection String Authentication):

  • connection - Azure Storage 계정의 연결 문자열이에요.

pod identity 기반 인증:

  • Azure AD Workload Identity provider를 사용할 수 있어요.

예시 (Example)

apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
  name: azure-queue-auth
spec:
  podIdentity:
    provider: azure-workload
---
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
  name: azure-queue-scaledobject
  namespace: default
spec:
  scaleTargetRef:
    name: azurequeue-function
  triggers:
  - type: azure-queue
    metadata:
      # Required
      queueName: functionsqueue
      # Optional, required when pod identity is used
      accountName: storage-account-name
      # Optional: connection OR authenticationRef that defines connection
      connectionFromEnv: STORAGE_CONNECTIONSTRING_ENV_NAME # Default: AzureWebJobsStorage. Reference to a connection string in deployment
      # or authenticationRef as defined below
      #
      # Optional
      queueLength: "5" # default 5
      # Optional
      queueLengthStrategy: "all" # or visibleonly. Default: all
      cloud: Private
      endpointSuffix: queue.local.azurestack.external # Required when cloud=Private
    authenticationRef:
        name: azure-queue-auth # authenticationRef would need either podIdentity or define a connection parameter

더 알아보기 (Learn more)

큐의 길이를 목표 값에 맞추는 방식이라서, 처리 용량을 조절하면서 큐가 지나치게 쌓이는 걸 막을 수 있어요. 인증 방식과 queueLengthStrategy만 잘 골라두면 운영이 수월해져요.