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

Workflow 동시성 제한

원문 보기 위키 갱신

Workflow 동시성 제한 (Concurrency Limits)

Dapr Workflow의 동시성 제한을 구성해 동시에 실행되는 워크플로와 액티비티 수를 제어해 보아요. Dapr은 워크플로와 액티비티에 대해 두 가지 수준의 동시성 제한을 제공합니다.

  • 글로벌 제한(Global limits)은 스케줄러가 집행하며 모든 레플리카에 걸친 총합을 제어해요.
  • 사이드카별 제한(Per-sidecar limits)은 단일 Dapr 인스턴스가 동시에 실행할 수 있는 워크플로나 액티비티 수를 제어해요.

두 수준 모두 독립적으로 구성할 수 있고 함께 동작합니다. 글로벌 제한은 네임스페이스 전체의 용량 제약을 강제해요. 예를 들어 다운스트림 서비스의 요청 제한(rate limit)을 존중하기 위한 것이죠. 사이드카별 제한은 개별 인스턴스를 리소스 고갈로부터 보호합니다. 진정한 동시성 제한을 표현하고 싶다면 글로벌 제한을 선호하세요. 사이드카별 제한은 각 인스턴스에 독립적으로 적용되므로, 효과적인 네임스페이스 전체 제한은 사이드카별 값에 레플리카 수를 곱한 값이 됩니다. 따라서 스케일 업/다운 때마다 값이 달라져요. 반면 글로벌 제한은 레플리카가 몇 개 실행되든 총합이 동일하게 유지되는데, "한 번에 최대 N개"라고 말할 때 보통 의미하는 바가 바로 이거예요.

출처: Dapr 문서

본문

글로벌 제한 (Global limits)

글로벌 제한은 애플리케이션의 모든 레플리카에 걸친 최대치를 강제합니다. Dapr 스케줄러는 제한을 인스턴스들에 나누고, 제한에 도달하면 트리거를 보류했다가 용량이 확보되면 이를 발송해요. 레플리카가 몇 개 실행되든 총합이 고정되므로, 글로벌 제한은 진정한 동시성 제한을 표현하는 가장 정확한 방법입니다. 대부분의 워크로드에 권장되는 출발점이에요.

모든 워크플로 또는 모든 액티비티 (All workflows or all activities)

apiVersion: dapr.io/v1alpha1
kind: Configuration
metadata:
name: appconfig
spec:
workflow:
globalMaxConcurrentWorkflowInvocations: 50
globalMaxConcurrentActivityInvocations: 200

| Property | Type | Description | | globalMaxConcurrentWorkflowInvocations | int32 | Max concurrent workflow executions across all replicas. Default: unlimited. | | globalMaxConcurrentActivityInvocations | int32 | Max concurrent activity executions across all replicas. Default: unlimited. |

이름별 제한 (Per-name limits)

특정 워크플로나 액티비티 이름에 대해 동시성 제한을 설정할 수 있어요. 특정 워크플로나 액티비티가 요청 제한이 있는 외부 서비스를 호출할 때 유용합니다.

apiVersion: dapr.io/v1alpha1
kind: Configuration
metadata:
name: appconfig
spec:
workflow:
globalMaxConcurrentActivityInvocations: 200
activityConcurrencyLimits:
- name: SendEmail
maxConcurrent: 5
- name: CallPaymentAPI
maxConcurrent: 10
workflowConcurrencyLimits:
- name: OrderProcess
maxConcurrent: 20

| Property | Type | Description | | activityConcurrencyLimits | array | Per-activity-name concurrency limits. | | workflowConcurrencyLimits | array | Per-workflow-name concurrency limits. | | activityConcurrencyLimits[].name | string | Activity name to limit. | | activityConcurrencyLimits[].maxConcurrent | int32 | Max concurrent executions across all replicas for this activity. | | workflowConcurrencyLimits[].name | string | Workflow name to limit. | | workflowConcurrencyLimits[].maxConcurrent | int32 | Max concurrent executions across all replicas for this workflow. | 트리거는 적용 가능한 모든 제한을 만족해야 합니다. 예를 들어 globalMaxConcurrentActivityInvocations가 200이고 SendEmail의 이름별 제한이 5라면, 최대 5개의 SendEmail 액티비티가 실행될 수 있고, 모든 액티비티를 합친 값은 200을 넘을 수 없어요.

사이드카별 제한 (Per-sidecar limits)

사이드카별 제한은 단일 Dapr 사이드카 내부의 동시성을 제한합니다. 각 인스턴스에 독립적으로 적용되므로, 효과적인 네임스페이스 전체 용량은 레플리카 수에 비례해 커집니다. 사이드카당 제한 100인 레플리카가 10개라면 효과적인 네임스페이스 전체 용량은 최대 1000이 돼요. 따라서 사이드카별 제한은 진정한 네임스페이스 전체 동시성 제한을 강제하기보다, 개별 인스턴스를 리소스 고갈로부터 보호할 때 사용하세요.

apiVersion: dapr.io/v1alpha1
kind: Configuration
metadata:
name: appconfig
spec:
workflow:
maxConcurrentWorkflowInvocations: 100
maxConcurrentActivityInvocations: 1000

| Property | Type | Description | | maxConcurrentWorkflowInvocations | int32 | Max concurrent workflow executions per sidecar. Default: unlimited. | | maxConcurrentActivityInvocations | int32 | Max concurrent activity executions per sidecar. Default: unlimited. | 이 제한들은 서로 다른 워크플로나 액티비티 이름을 구분하지 않습니다. 사이드카에서 실행되는 모든 워크플로와 액티비티에 적용돼요.

수준 간 상호작용 (How the levels interact)

| Limit type | Scope | Enforcement point | Effect of scaling replicas | | Global (type) | All replicas | Scheduler | Fixed total regardless of replicas | | Global (per-name) | All replicas | Scheduler | Fixed total regardless of replicas | | Per-sidecar | Single instance | Dapr sidecar | Effective max = limit x replicas | 사이드카별 제한과 글로벌 제한이 모두 구성되면 둘 다 적용됩니다. 글로벌 제한은 네임스페이스 전체 총합이 설정값을 넘지 못하게 막고, 사이드카별 제한은 어떤 단일 인스턴스도 너무 많은 로컬 리소스를 소비하지 못하게 합니다.

여러 스케줄러 레플리카에서 글로벌 제한이 동작하는 방식 (How global limits work with multiple scheduler replicas)

스케줄러는 글로벌 제한을 인스턴스들에 내림 나눗셈(floor division)으로 균등하게 나눕니다. 글로벌 제한이 100이고 스케줄러 레플리카가 3개라면, 각 스케줄러는 로컬 제한 33을 강제하고, 효과적인 네임스페이스 최대치는 99가 돼요. 이렇게 해서 설정된 제한을 절대 넘지 않음을 보장합니다.

다른 요청 제한 옵션과의 비교 (Comparison with other rate limiting options)

Dapr은 동시성과 요청 제한을 제어하는 여러 방법을 제공합니다.

| Approach | What it controls | Granularity | Scope | | Workflow concurrency limits | Workflow and activity executions | Per-type or per-name | Per-sidecar or global | | app-max-concurrency | All requests and events to an app | All traffic | Per-sidecar | | Rate limit middleware | HTTP requests per second | Per remote IP | Per-sidecar |

  • Dapr Configuration 레퍼런스
  • 애플리케이션 동시성 및 요청 제한 제어
  • Rate limit 미들웨어
  • Workflow 개요
  • Workflow API 레퍼런스

더 알아보기 (Learn more)