RabbitMQ 큐 스케일러
이 문서는 RabbitMQ 큐용 rabbitmq 트리거에 대해 설명합니다. 큐 길이, 메시지 전송/수신율 등 다양한 모드로 어떻게 스케일링하는지 강사가 설명하듯 안내해 드릴게요.
출처: 문서
본문
트리거 명세 (Trigger Specification)
이 명세는 RabbitMQ 큐용 rabbitmq 트리거를 설명합니다.
triggers:
- type: rabbitmq
metadata:
host: amqp://<host>:<port>/<vhost> # Optional. If not specified, it must be done by using TriggerAuthentication.
protocol: auto # Optional. Specifies protocol to use, either `amqp`, `http`, or `auto` for auto-detection based on the `host` value. Default value is `auto`.
mode: QueueLength # Supported modes are `QueueLength`, `MessageRate`, `DeliverGetRate`, `PublishedToDeliveredRatio` or `ExpectedQueueConsumptionTime`
value: "100.50" # A value defining the threshold (per instance) that, when exceeded, triggers the scaling.
activationValue: "10.5" # Optional. Activation threshold, which by default is 0.
queueName: testqueue # Name of the queue.
vhostName: / # Optional. If not specified, use the VHost in the `host` connection string. Required for Azure AD Workload Identity authorization (see below).
# You can use existing environment variables to read configuration from. For details see "Parameters list" section.
hostFromEnv: RABBITMQ_HOST # Optional. You can use this instead of `host` parameter.
usernameFromEnv: RABBITMQ_USERNAME # Optional. You can use this instead of `TriggerAuthentication`.
passwordFromEnv: RABBITMQ_PASSWORD # Optional. You can use this instead of `TriggerAuthentication`.
unsafeSsl: true # Optional. Whether to allow unsafe SSL connections.
timeout: 1000 # Optional. Custom timeout for the HTTP client used in this scaler.
파라미터 목록:
- host - ://:/vhost 형식의 RabbitMQ 호스트 주소. 프로토콜이 HTTP라면 호스트는 http://:// 형식을 따를 수 있습니다. 예를 들어 해석된 host 값은 amqp://guest:***@localhost:5672/vhost 또는 http://guest:password@localhost:15672/path/vhost일 수 있습니다. host에 vhost가 없으면 후행 슬래시가 필요합니다. 예: http://guest:password@localhost:5672/. username과 password를 사용할 때는 hostFromEnv 또는 TriggerAuthentication 사용을 고려하세요.
- queueName - 필요한 정보와 통계를 읽을 큐 이름.
- mode - 트리거 모드. 추가 세부 사항은 올바른 트리거 모드 선택을 참고하세요. 다음 중 하나일 수 있습니다:
- QueueLength - 큐 안의 메시지 수로 트리거
- MessageRate - 큐가 보고하는 게시(발행)율로 트리거
- DeliverGetRate - 큐가 보고하는 전달된 메시지(소비자에게 또는 basic.get에 대한 응답으로 전달된, 확인됨/미확인 모두)의 비율로 트리거
- PublishedToDeliveredRatio - MessageRate와 DeliverGetRate의 비율 값으로 트리거
- ExpectedQueueConsumptionTime - 현재 큐에 있는 모든 메시지를 소비하는 데 걸리는 예상 시간(초) 값으로 트리거합니다 (QueueLength, MessageRate, DeliverGetRate 메트릭을 사용).
- value - 초과하면 스케일링을 트리거하는 임계값(인스턴스당)을 정의하는 값 (트리거 모드에 따라 부동 소수점 숫자일 수 있습니다).
- activationValue - 스케일러를 활성화하기 위한 목표 값. activation에 대해 자세히 알아보세요 (기본값: 0; 선택; 부동 소수점 숫자일 수 있습니다).
- protocol - 통신에 사용할 프로토콜 (값: auto, http, amqp; 기본값: auto; 선택).
- vhostName - 연결에 사용할 VHost로, host/hostFromEnv의 연결 문자열에 설정된 VHost를 재정의합니다 (기본적으로 선택이지만, Azure AD Workload Identity 인증을 사용하면 필수입니다).
- queueLength - 사용 중단(deprecated): 대신 mode: QueueLength와 value: ## 을 사용하세요. 스케일러에 전달되는 큐 길이의 임계값을 정의합니다. 예를 들어 파드 하나가 메시지 10개를 처리할 수 있다면 큐 길이 목표를 10으로 설정하세요. 큐 안의 실제 메시지 수가 30이라면 스케일러는 3개 파드로 확장합니다. publishRate가 지정되지 않으면 기본값은 20이며, publishRate가 지정되면 이 트리거에서는 queueLength가 비활성화됩니다.
- useRegex - 큐 이름을 전체 이름 대신 사용하고 싶을 때(queueName 파라미터에서) regex를 사용할 수 있게 하는 파라미터 (값: true, false; 기본값: false; 선택; http 프로토콜을 사용하는 호스트에만 적용).
- pageSize - 페이지 크기를 설정할 수 있는 파라미터 (기본값: 100; 선택; useRegex가 true로 설정된 경우에만 적용).
- operation - useRegex가 활성화된 경우 메시지 수를 계산하는 데 적용되는 연산 (값: sum, max, avg; 기본값: sum; 선택).
- timeout - 이 특정 트리거에 대한 밀리초 단위의 타임아웃. 이 값은 KEDA_HTTP_DEFAULT_TIMEOUT에 정의된 값을 재정의합니다 (선택; http 프로토콜을 사용하는 호스트에만 적용).
- excludeUnacknowledged - QueueLength 값이 확인되지 않은(unacknowledged) 메시지를 제외하도록 지정하려면 true로 설정합니다 (준비된 메시지만; 값: true, false; 기본값: false; 선택; http 프로토콜을 사용하는 호스트에만 적용).
- unsafeSsl - 안전하지 않은 SSL 연결을 허용할지 여부 (값: true, false, 기본값: false).
일부 파라미터는 metadata에 직접 설정하는 대신 환경 변수로 제공할 수 있습니다:
- hostFromEnv - 선택한 환경 변수에서 RabbitMQ 서버의 host와 port를 읽습니다 (host 파라미터와 비슷한 형식).
- usernameFromEnv - 선택한 환경 변수에서 username을 읽으며, 브로커의 관리 엔드포인트에 연결하는 데 사용됩니다.
- passwordFromEnv - 선택한 환경 변수에서 password를 읽으며, 브로커의 관리 엔드포인트에 연결하는 데 사용됩니다.
💡 참고:
- host/hostFromEnv는 호스트 슬래시 뒤에 선택적 VHost 이름을 가지며, 이는 API 요청 범위를 지정하는 데 사용됩니다
- host/hostFromEnv 또는 TriggerAuthentication을 사용할 때, 제공된 암호에는 특수 문자가 포함될 수 없습니다
- 트리거 모드 MessageRate, DeliverGetRate, PublishedToDeliveredRatio, ExpectedQueueConsumptionTime은 http 프로토콜이 필요합니다
- useRegex를 true로 설정하는 것도 protocol을 http로 설정해야 합니다
⚠ 중요:
- 확인되지 않은(unacknowledged) 메시지가 있고 이를 스케일링에 포함하고 싶다면 반드시 http 프로토콜을 사용하세요 (REST API 인터페이스만 이를 계산할 수 있습니다).
- 많은 것에 대해 스케일링하고 싶다면 ScaledObject에 원하는 모든 트리거를 정의해야 합니다. HPA는 각 트리거를 독립적으로 고려해 가장 큰 결과를 기준으로 스케일링합니다.
올바른 트리거 모드 선택 (Choosing the right trigger mode)
아래에서 가장 일반적인 사용 시나리오와 함께 사용 가능한 트리거 모드를 확인할 수 있습니다:
- QueueLength - 주로 메시지 소비 서비스를 스케일링하는 데 사용되며, 큐 안의 메시지 수를 선택한 정상 수준으로 유지하고자 할 때 적합합니다.
- MessageRate - 주로 메시지 소비 서비스를 스케일링하는 데 사용되며, 소비율을 메시지 게시율과 같거나 그 이상으로 유지하고자 할 때 적합합니다.
- DeliverGetRate - 이 특정 트리거는 실제로 PublishedToDeliveredRatio 트리거 구현의 부산물입니다 (복합 메트릭의 일부로 scalingModifiers 안에서 사용되도록 구현되었지만, 일부 시나리오에서는 여전히 용도가 있습니다). 예를 들어 잘 알려진 소비자 서비스 성능 범위가 있다고 가정하면, DeliverGetRate 트리거는 게시율을 높이기 위해 메시지 게시 서비스를 확장하는 데 사용할 수 있습니다. 이 특정 예에서는 게시율 상한을 다른 트리거나 maxReplicaCount로 제대로 제한해야 무한 확장(브로커나 소비자, 또는 둘 다 과부하시킬 수 있음)을 막을 수 있습니다.
- PublishedToDeliveredRatio - 이 트리거는 주로 게시율과 소비율을 안정적인 수준으로 유지하기 위해 소비자 파드 스케일링을 제어하는 데 사용됩니다. 이 경우 동작 원리는 다음과 같습니다:
- 게시율이 value보다 크면(보통 1보다 약간 큰 값), 트리거가 스케일 아웃 프로세스를 시작해 더 많은 소비자 파드를 띄웁니다
- 게시율이 소비율과 같으면(값 1), 소비자 용량이 진행 중인 메시지 처리를 다루기에 충분하다는 지표이므로 풀에 추가 파드를 넣을 필요가 없습니다
- 비율이 1 미만이면 HPA가 일부 소비자를 정상적으로 내리면서도 메시지 처리율은 안정적인 수준으로 유지할 수 있습니다
- ExpectedQueueConsumptionTime - 주로 소비자 파드를 스케일링하는 데 사용되는 트리거로, 큐에 있는 모든 메시지를 소비자에게 전달하는 데 걸리는 예상 시간의 추정값을 사용합니다. 이 특정 시나리오에서 활성화되면 반환된 메트릭은 게시율이 높아지거나 현재 활성 소비자 수의 성능이 저하되어 메시지 수가 증가하고 있음을 나타냅니다. pollingInterval을 올바르게 설정하는 것에 의존합니다 (자세한 내용은 아래 참조).
⚠ 중요:
- DeliverGetRate, PublishedToDeliveredRatio, ExpectedQueueConsumptionTime에서는 트리거 구성에 metricType: Value를 설정해 확장된 모든 파드의 평균값이 아닌 절대 메트릭 값에 의존하는 것이 좋습니다. 참고: triggers.metricType와 scalingModifiers.metricType를 참조하세요.
- PublishedToDeliveredRatio를 사용할 때, 게시율 대비 소비율이 안정적이라고 해서 소비자 풀이 작업을 하기에 알맞은 크기라는 뜻은 아닐 수 있습니다. 메시지 소비 능력은 시간이 지나면서 변할 수 있어 실제로 필요한 것보다 훨씬 많은 수의 소비자가 생길 수 있기 때문입니다. 따라서 다른, 아마도 외부 메트릭(예: 소비자 수, prefetch 버퍼 크기, 소비자 성능 등)을 사용해 소비자 풀 크기를 주기적으로 재평가하는 것을 권장합니다.
- ExpectedQueueConsumptionTime 트리거 모드는 선택한 큐가 모든 메시지(샘플 프로빙 중 게시된 메시지의 추정 수 포함)를 비우는 예상 시간(초)에 기반하므로, pollingInterval을 1초로 설정한 채 사용해야 합니다. 다만 이러한 잦은 폴링이 비쌀 수 있는 경우라면 scalingModifiers에서 (ExpectedQueueConsumptionTime - (QueueLength / DeliverGetRate)) * pollingInterval + (QueueLength / DeliverGetRate) 같은 공식으로 추가 트리거 값을 사용하는 것이 좋습니다.
인증 파라미터 (Authentication Parameters)
TriggerAuthentication CRD를 사용해 RabbitMQ에 연결하고 인증합니다:
-
AMQP의 경우 URI는 amqp://guest:***@localhost:5672/vhost 와 비슷해야 합니다.
-
HTTP의 경우 URI는 http://guest:password@localhost:15672/path/vhost 와 비슷해야 합니다. 포트를 구성하는 방법에 대한 자세한 내용은 RabbitMQ Ports 섹션을 참고하세요.
-
vhostName - 연결에 사용할 VHost로, host/hostFromEnv의 연결 문자열에 설정된 VHost를 재정의합니다 (선택이지만, Azure AD Workload Identity 인증을 사용하면 필수).
사용자 이름과 암호 기반 인증 (Username and Password based authentication)
이 방식은 민감한 자격 증명을 연결 문자열과 분리해서 저장하고 관리할 수 있게 해 줍니다:
- username - 브로커의 관리 엔드포인트에 연결하는 데 사용할 사용자 이름.
- password - 브로커의 관리 엔드포인트에 연결하는 데 사용할 암호.
💡 참고: username 또는 password가 TriggerAuthentication이나 환경 변수에 설정되어 있으면, host 파라미터에 제공된 자격 증명보다 우선합니다.
TLS 인증 (TLS authentication)
- tls - RabbitMQ에 SSL 인증을 활성화하려면 enable로 설정합니다. 설정하지 않으면 RabbitMQ에 TLS가 사용되지 않습니다. 유효한 값은 enable 또는 disable입니다 (선택; 기본값은 disable).
- ca - TLS 클라이언트 인증용 인증 기관(certificate authority) 파일 (선택).
- cert - 클라이언트 인증용 인증서 (선택).
- key - 클라이언트 인증용 인증서 키 (선택).
💡 참고: AMQPS 프로토콜로 RabbitMQ host를 사용하려면 TLS 설정을 활성화하고 필요한 파라미터를 전달해야 합니다.
Azure Workload Identity 인증 (Azure Workload Identity authentication)
OIDC를 지원하는 RabbitMQ(>= 3.11)의 경우, podIdentity.provider = azure-workload와 함께 workloadIdentityResource 파라미터를 사용하는 TriggerAuthentication CRD를 사용할 수 있습니다. workloadIdentityResource는 Azure AD의 App Registration 애플리케이션 식별자를 담습니다. 이 경우 host URI의 username:password 부분은 생략해야 하고, vHostName은 ScaledObject에서 명시적으로 설정해야 합니다. 현재 AKS Workload Identity에서는 HTTP 프로토콜만 지원됩니다.
OAuth2 인증 (OAuth2 authentication)
OIDC를 지원하는 RabbitMQ(>= 3.11)의 경우, oauth2 스펙과 함께 TriggerAuthentication CRD를 사용할 수 있습니다. 전체 TriggerAuthentication.spec.oauth2 스키마는 OAuth2 인증 공급자 문서를 참고하세요. 이 경우 host URI의 username:password 부분은 생략해야 합니다. 현재 HTTP 프로토콜만 지원됩니다.
구성 예시 (Configuration examples)
AMQP 프로토콜:
apiVersion: v1
kind: Secret
metadata:
name: keda-rabbitmq-secret
data:
host: <AMQP URI connection string> # base64 encoded value of format amqp://guest:***@localhost:5672
vhostName: vhost
---
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: keda-trigger-auth-rabbitmq-conn
namespace: default
spec:
secretTargetRef:
- parameter: host
name: keda-rabbitmq-secret
key: host
- parameter: vhostName
name: keda-rabbitmq-secret
key: vhostName
---
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: rabbitmq-scaledobject
namespace: default
spec:
scaleTargetRef:
name: rabbitmq-deployment
triggers:
- type: rabbitmq
metadata:
protocol: amqp
queueName: testqueue
mode: QueueLength
value: "20"
authenticationRef:
name: keda-trigger-auth-rabbitmq-conn
사용자 이름과 암호 인증을 사용한 AMQP 프로토콜:
apiVersion: v1
kind: Secret
metadata:
name: keda-rabbitmq-secret
data:
host: <AMQP URI connection string> # base64 encoded value of format amqp://localhost:5672/vhost (no username/password)
username: <username> # base64 encoded value of username
password: <password> # base64 encoded value of password
---
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: keda-trigger-auth-rabbitmq-conn
namespace: default
spec:
secretTargetRef:
- parameter: host
name: keda-rabbitmq-secret
key: host
- parameter: username
name: keda-rabbitmq-secret
key: username
- parameter: password
name: keda-rabbitmq-secret
key: password
---
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: rabbitmq-scaledobject
namespace: default
spec:
scaleTargetRef:
name: rabbitmq-deployment
triggers:
- type: rabbitmq
metadata:
protocol: amqp
queueName: testqueue
mode: QueueLength
value: "20"
authenticationRef:
name: keda-trigger-auth-rabbitmq-conn
TLS 인증을 사용한 AMQPS 프로토콜:
apiVersion: v1
kind: Secret
metadata:
name: keda-rabbitmq-secret
data:
host: <AMQPS URI connection string> # base64 encoded value of format amqps://guest:password@localhost:5672/vhost
tls: "enable"
ca: <your ca>
cert: <your cert>
key: <your key>
---
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: keda-trigger-auth-rabbitmq-conn
namespace: default
spec:
secretTargetRef:
- parameter: host
name: keda-rabbitmq-secret
key: host
- parameter: tls
name: keda-rabbitmq-secret
key: tls
- parameter: ca
name: keda-rabbitmq-secret
key: ca
- parameter: cert
name: keda-rabbitmq-secret
key: cert
- parameter: key
name: keda-rabbitmq-secret
key: key
---
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: rabbitmq-scaledobject
namespace: default
spec:
scaleTargetRef:
name: rabbitmq-deployment
triggers:
- type: rabbitmq
metadata:
protocol: amqp
queueName: testqueue
mode: QueueLength
value: "20"
authenticationRef:
name: keda-trigger-auth-rabbitmq-conn
HTTP 프로토콜 (QueueLength 트리거):
apiVersion: v1
kind: Secret
metadata:
name: keda-rabbitmq-secret
data:
host: <HTTP API endpoint> # base64 encoded value of format http://guest:password@localhost:15672/path/vhost
---
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: keda-trigger-auth-rabbitmq-conn
namespace: default
spec:
secretTargetRef:
- parameter: host
name: keda-rabbitmq-secret
key: host
---
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: rabbitmq-scaledobject
namespace: default
spec:
scaleTargetRef:
name: rabbitmq-deployment
triggers:
- type: rabbitmq
metadata:
protocol: http
queueName: testqueue
mode: QueueLength
value: "20"
authenticationRef:
name: keda-trigger-auth-rabbitmq-conn
HTTP 프로토콜 (MessageRate와 QueueLength 트리거):
apiVersion: v1
kind: Secret
metadata:
name: keda-rabbitmq-secret
data:
host: <HTTP API endpoint> # base64 encoded value of format http://guest:password@localhost:15672/path/vhost
---
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: keda-trigger-auth-rabbitmq-conn
namespace: default
spec:
secretTargetRef:
- parameter: host
name: keda-rabbitmq-secret
key: host
---
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: rabbitmq-scaledobject
namespace: default
spec:
scaleTargetRef:
name: rabbitmq-deployment
triggers:
- type: rabbitmq
metadata:
protocol: http
queueName: testqueue
mode: QueueLength
value: "20"
authenticationRef:
name: keda-trigger-auth-rabbitmq-conn
- type: rabbitmq
metadata:
protocol: http
queueName: testqueue
mode: MessageRate
value: "100"
authenticationRef:
name: keda-trigger-auth-rabbitmq-conn
HTTP 프로토콜 (QueueLength 트리거) 및 useRegex 활성화:
apiVersion: v1
kind: Secret
metadata:
name: keda-rabbitmq-secret
data:
host: <HTTP API endpoint> # base64 encoded value of format http://guest:password@localhost:15672/path/vhost
---
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: keda-trigger-auth-rabbitmq-conn
namespace: default
spec:
secretTargetRef:
- parameter: host
name: keda-rabbitmq-secret
key: host
---
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: rabbitmq-scaledobject
namespace: default
spec:
scaleTargetRef:
name: rabbitmq-deployment
triggers:
- type: rabbitmq
metadata:
protocol: http
queueName: ^.*incoming$
mode: QueueLength
value: "20"
useRegex: "true"
operation: max
authenticationRef:
name: keda-trigger-auth-rabbitmq-conn
HTTP 프로토콜 (QueueLength 트리거) 및 Azure Workload Identity:
apiVersion: v1
kind: Secret
metadata:
name: keda-rabbitmq-secret
data:
host: <HTTP API endpoint> # base64 encoded value of format http://localhost:15672/ !! no password !!
clientId: <RabbitMQ AzureAD App Registration Client ID> # base64 encoded value of Client ID (same as for Rabbit's auth_oauth2.resource_server_id)
---
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: keda-trigger-auth-rabbitmq-conn
namespace: default
spec:
podIdentity:
provider: azure-workload
secretTargetRef:
- parameter: host
name: keda-rabbitmq-secret
key: host
- parameter: workloadIdentityResource
name: keda-rabbitmq-secret
key: clientId
---
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: rabbitmq-scaledobject
namespace: default
spec:
scaleTargetRef:
name: rabbitmq-deployment
triggers:
- type: rabbitmq
metadata:
protocol: http
vHostName: /
queueName: testqueue
mode: QueueLength
value: "20"
authenticationRef:
name: keda-trigger-auth-rabbitmq-conn
HTTP 프로토콜 (DeliverGetRate 트리거)
apiVersion: v1
kind: Secret
metadata:
name: keda-rabbitmq-secret
data:
host: <HTTP API endpoint> # base64 encoded value of format http://guest:password@localhost:15672/path/vhost
---
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: keda-trigger-auth-rabbitmq-conn
namespace: default
spec:
secretTargetRef:
- parameter: host
name: keda-rabbitmq-secret
key: host
---
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: rabbitmq-scaledobject
namespace: default
spec:
scaleTargetRef:
name: rabbitmq-deployment
triggers:
- type: rabbitmq
metricType: Value
metadata:
protocol: http
queueName: testqueue
mode: DeliverGetRate
value: "30"
authenticationRef:
name: rabbitmq-trigger-auth
HTTP 프로토콜 (PublishedToDeliveredRatio 트리거)
apiVersion: v1
kind: Secret
metadata:
name: keda-rabbitmq-secret
data:
host: <HTTP API endpoint> # base64 encoded value of format http://guest:password@localhost:15672/path/vhost
---
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: keda-trigger-auth-rabbitmq-conn
namespace: default
spec:
secretTargetRef:
- parameter: host
name: keda-rabbitmq-secret
key: host
---
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: rabbitmq-scaledobject
namespace: default
spec:
scaleTargetRef:
name: rabbitmq-deployment
triggers:
- type: rabbitmq
metricType: Value
metadata:
protocol: http
queueName: testqueue
mode: PublishedToDeliveredRatio
value: "1.1"
authenticationRef:
name: rabbitmq-trigger-auth
HTTP 프로토콜 (PublishedToDeliveredRatio 트리거를 scalingModifiers와 함께 사용)
apiVersion: v1
kind: Secret
metadata:
name: keda-rabbitmq-secret
data:
host: <HTTP API endpoint> # base64 encoded value of format http://guest:password@localhost:15672/path/vhost
---
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: keda-trigger-auth-rabbitmq-conn
namespace: default
spec:
secretTargetRef:
- parameter: host
name: keda-rabbitmq-secret
key: host
---
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: rabbitmq-scaledobject
namespace: default
spec:
scaleTargetRef:
name: rabbitmq-deployment
triggers:
- type: rabbitmq
metricType: Value
name: p2d_ratio
metadata:
protocol: http
queueName: testqueue
mode: PublishedToDeliveredRatio
value: "1"
authenticationRef:
name: rabbitmq-trigger-auth
- type: rabbitmq
name: qlen
metadata:
protocol: http
queueName: testqueue
mode: QueueLength
value: "100"
authenticationRef:
name: rabbitmq-trigger-auth
advanced:
# Bind QueueLength and PublishedToDeliveredRatio together to control trigger value
scalingModifiers:
metricType: Value
# Trigger if either one of conditions is met:
# - publishing to delivery rate exceeds factor of 1.2
# - queue length contains more than 1.2K messages
formula: "max(p2d_ratio, qlen/1000)"
target: 1.2
HTTP 프로토콜 (ExpectedQueueConsumptionTime 트리거)
apiVersion: v1
kind: Secret
metadata:
name: keda-rabbitmq-secret
data:
host: <HTTP API endpoint> # base64 encoded value of format http://guest:password@localhost:15672/path/vhost
---
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: keda-trigger-auth-rabbitmq-conn
namespace: default
spec:
secretTargetRef:
- parameter: host
name: keda-rabbitmq-secret
key: host
---
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: rabbitmq-scaledobject
namespace: default
spec:
scaleTargetRef:
name: rabbitmq-deployment
pollingInterval: 1
triggers:
- type: rabbitmq
metricType: Value
name: eqct
metadata:
protocol: http
queueName: testqueue
mode: ExpectedQueueConsumptionTime
value: "20"
authenticationRef:
name: rabbitmq-trigger-auth
더 알아보기 (Learn more)
RabbitMQ 스케일러는 모드 선택이 핵심이에요. 단순히 큐에 쌓인 메시지 수가 기준이라면 QueueLength, 게시/소비율을 비교하려면 MessageRate나 PublishedToDeliveredRatio를 고르면 됩니다. HTTP 프로토콜을 써야 하는 모드가 있다는 점도 꼭 확인해 주세요.