정확히 한 번 모드. 이 모드는 모든 Dataflow 스트리밍 작업의 기본값입니다. 이 모드에서 Dataflow는 데이터가 파이프라인을 통해 이동할 때 레코드가 삭제되거나 중복되지 않도록 합니다.
적어도 한 번 모드. 이 모드는 레코드가 최소 한 번 처리되도록 보장합니다(즉, 입력 레코드가 손실되지 않음). 그러나 이 모드에서는 중복 레코드가 가능합니다. 중복을 허용할 수 있는 사용 사례의 경우 적어도 한 번 모드는 작업 비용과 지연 시간을 크게 낮출 수 있습니다.
사용할 스트리밍 모드 선택
파이프라인의 정확한 결과와 예측 가능한 시맨틱스를 보장해야 하는 경우에는 적어도 한 번 모드를 선택하세요. 예를 들면 다음과 같습니다.
한 번만 처리되는 레코드에 의존하는 비즈니스에 중요한 사용 사례. 예를 들어 사기 감지, 네트워크 위협 감지, 전자상거래 인벤토리 대시보드 등이 있습니다.
워크로드가 중복 레코드를 허용하고 비용 또는 지연 시간을 줄여야 하는 경우 적어도 한 번 스트리밍 모드를 선택합니다. 예를 들면 다음과 같습니다.
Dataflow에서 중복 삭제가 다운스트림으로 수행되는 워크로드. 예를 들어 BigQuery 또는 SQL 데이터 저장소에 쓰는 파이프라인입니다.
집계가 없는 맵 전용 파이프라인. 예를 들어 로그 처리, 변경 데이터 캡처 또는 추출, 변환, 로드(ETL) 작업이 포함되며 이 작업에서는 파이프라인이 스키마 변환과 같은 요소별 변환만 수행합니다.
출력 싱크가 1회만 전송을 보장할 수 없는 파이프라인(예: Pub/Sub). 이 경우 파이프라인 내의 중복 삭제가 불필요할 수 있으며 적어도 한 번 스트리밍 모드의 비용 및 지연 시간 감소 이점을 얻을 수 있습니다.
Pub/Sub에서 읽는 파이프라인. Pub/Sub에서 읽기는 적어도 한 번 모드를 사용할 때 크게 최적화됩니다.
추가 고려사항
적어도 한 번 모드는 파이프라인의 비용과 지연 시간을 크게 줄여줄 수 있습니다. 정확한 영향은 파이프라인의 세부정보에 따라 다릅니다. 실제 부하에서 적어도 한 번 스트리밍을 테스트하여 영향을 평가합니다.
적어도 한 번 모드를 사용하는 경우 중복 레코드 비율은 재시도 횟수에 따라 다릅니다. 기준 비율은 일반적으로 낮습니다(<1%). 그러나 워커 노드가 실패하거나 다른 조건으로 인해 RPC 호출이 반복되면 급증이 발생할 수 있습니다.
스트리밍 모드는 스트리밍 엔진이 레코드를 처리하는 방식에 영향을 미치지만 I/O 커넥터의 시맨틱스는 변경하지 않습니다. I/O 시맨틱스를 스트리밍 모드에 맞추는 것이 좋습니다. 예를 들어 BigQuery I/O 커넥터에 적어도 한 번 스트리밍 모드를 사용하는 경우 쓰기 모드를 STORAGE_API_AT_LEAST_ONCE로 설정합니다.
적어도 한 번 스트리밍을 사용하는 경우 Google에서 제공하는 Dataflow 템플릿에서 이 옵션을 자동으로 사용 설정합니다.
Map과 같은 요소별 변환은 항상 멱등성을 갖지는 않습니다. 예를 들어 메시지를 수신하고 현재 타임스탬프를 추가하는 함수를 생각해 보세요. 이 경우 중복 레코드가 여러 개의 고유한 출력을 생성할 수 있습니다.
이 파이프라인에는 적어도 한 번 모드가 적합하지 않을 수 있습니다.
스트리밍 모드 설정
정확히 한 번 처리는 모든 Dataflow 작업의 기본 설정입니다. 적어도 한 번 스트리밍 모드를 사용 설정하려면 streaming_mode_at_least_once서비스 옵션을 설정합니다.
이러한 메타데이터 필드를 사용하면 Google Cloud 콘솔에서 템플릿을 배포할 때 사용자가 스트리밍 모드를 선택할 수 있습니다. defaultStreamingMode 필드는 선택사항이며 템플릿의 기본 스트리밍 모드를 지정합니다. defaultStreamingMode를 지정하지 않고 템플릿이 두 모드를 모두 지원하는 경우 정확히 한 번 모드가 기본값입니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-04-21(UTC)"],[[["\u003cp\u003eDataflow supports two streaming modes: exactly-once, which ensures no data is lost or duplicated, and at-least-once, which guarantees no data loss but may result in duplicates.\u003c/p\u003e\n"],["\u003cp\u003eExactly-once mode is the default for all Dataflow streaming jobs and is recommended for pipelines requiring precise results, such as those involving aggregations or business-critical applications like fraud detection.\u003c/p\u003e\n"],["\u003cp\u003eAt-least-once mode can significantly reduce costs and latency and is suitable for workloads that can tolerate duplicate records, such as those with downstream deduplication or map-only pipelines.\u003c/p\u003e\n"],["\u003cp\u003eThe choice of streaming mode affects how Streaming Engine processes data but does not alter the semantics of I/O connectors; it is recommended to use the right connector to complement the streaming mode.\u003c/p\u003e\n"],["\u003cp\u003eYou can set at-least-once streaming mode using the \u003ccode\u003estreaming_mode_at_least_once\u003c/code\u003e service option in Java, Python, Go, console, or via the REST API, and it will be automatically applied in Dataflow templates when they support it.\u003c/p\u003e\n"]]],[],null,["# Set the pipeline streaming mode\n\nDataflow supports two modes for streaming jobs:\n\n- **Exactly-once mode**. This mode is the default for all Dataflow streaming jobs. In this mode, Dataflow ensures that records are not dropped or duplicated as the data moves through the pipeline.\n- **At-least-once mode**. This mode guarantees that records are processed at least once (that is, no input records are lost). However, duplicate records are possible in this mode. For use cases that can tolerate duplicates, at-least-once mode can significantly lower the cost and latency of your job.\n\nChoose which streaming mode to use\n----------------------------------\n\nChoose exactly-once mode if you need to ensure exact results from the pipeline\nand predictable semantics. For example:\n\n- Pipelines with [aggregations](https://beam.apache.org/documentation/basics/#aggregation), such as count, sum, or mean.\n- Business-critical use cases that rely on records being processed once and only once. Examples include fraud detection, network threat detection, and ecommerce inventory dashboards.\n\nChoose at-least-once streaming mode if your workload can tolerate duplicated\nrecords and might benefit from reduced cost or latency. For example:\n\n- Workloads where deduplication is performed downstream from Dataflow. For example, pipelines that write to BigQuery or a SQL datastore.\n- Map-only pipelines with no aggregations. Examples include log processing, change data capture, or extract, transform, and load (ETL) jobs, in which the pipeline performs only per-element transforms, such as schema translation.\n- Pipelines where the output sink can't guarantee exactly-once delivery, such as Pub/Sub. In that case, deduplication *within* the pipeline might be unnecessary, and you can benefit from the reduced cost and latency of at-least-once streaming mode.\n- Pipelines that read from Pub/Sub. Reading from Pub/Sub is significantly optimized when using at-least-once mode.\n\n### Additional considerations\n\n- At-least-once mode can significantly reduce the cost and latency of a\n pipeline. The exact impact depends on the specifics of the pipeline. Test\n at-least-once streaming under realistic loads to evaluate the impact.\n\n- When using at-least-once mode, the rate of duplicate records depends on the\n number of retries. The baseline rate is typically low (\\\u003c1%). However, spikes\n can occur if worker nodes fail or other conditions cause repeated RPC calls.\n\n- The streaming mode affects how Streaming Engine processes records, but does\n not change the semantics of I/O connectors. It is recommended to align your\n I/O semantics with the streaming mode. For example, if you use at-least-once\n streaming mode with the\n [BigQuery I/O connector](/dataflow/docs/guides/write-to-bigquery),\n set the write mode to `STORAGE_API_AT_LEAST_ONCE`.\n [Google-provided Dataflow templates](/dataflow/docs/guides/templates/provided-templates)\n automatically enable this option when you use at-least-once streaming.\n\n- Element-wise transforms such as `Map` are not always idempotent. For example,\n consider a function that receives a message and appends the current timestamp\n to it. In that case, a duplicate record can produce several distinct outputs.\n At-least-once mode might not be appropriate for that pipeline.\n\nSet the streaming mode\n----------------------\n\nExactly-once processing is the default setting for all Dataflow\njobs. To enable at-least-once streaming mode, set the\n`streaming_mode_at_least_once`\n[service option](/dataflow/docs/reference/service-options). \n\n### Java\n\n --dataflowServiceOptions=streaming_mode_at_least_once\n\n### Python\n\n --dataflow_service_options=streaming_mode_at_least_once\n\n### Go\n\n --dataflow_service_options=streaming_mode_at_least_once\n\nIf you don't specify the `streaming_mode_at_least_once` option, then\nDataflow uses exactly-once streaming mode.\n\nIf you set the `streaming_mode_at_least_once` option, Dataflow\nautomatically enables [Streaming Engine](/dataflow/docs/streaming-engine) with\n[resource-based billing](/dataflow/docs/streaming-engine#compute-unit-pricing).\n\nTo update the streaming mode on a running job,\n[launch a replacement job](/dataflow/docs/guides/updating-a-pipeline#Launching).\n\nSelect the streaming mode for a template\n----------------------------------------\n\nTo select the streaming mode when you run a Dataflow streaming\ntemplate, perform the following steps: \n\n### Console\n\n1. In the Google Cloud console, go to the Dataflow **Jobs**\n page.\n\n [Go to Jobs](https://console.cloud.google.com/dataflow/jobs)\n2. Click **Create job from template**.\n\n3. Select the template that you want to run from the\n **Dataflow template** drop-down menu.\n\n4. For **Streaming mode**, select the streaming mode. If the template supports\n only one mode, then this option is disabled.\n\n### gcloud\n\nTo enable at-least-once mode, set the `streaming_mode_at_least_once` option\nin the `additional-experiments` flag: \n\n --additional-experiments=streaming_mode_at_least_once\n\nTo enable exactly-once mode, set the `streaming_mode_exactly_once` option\nin the `additional-experiments` flag: \n\n --additional-experiments=streaming_mode_exactly_once\n\nThese two options are mutually exclusive. If you don't set one of these\noptions, then the template defaults to a streaming mode that is determined by\nthe template metadata. For more information, see\n[Custom templates](#custom-templates).\n\n### REST\n\nUse the `additionalExperiments` field in the\n[`FlexTemplateRuntimeEnvironment`](/dataflow/docs/reference/rest/v1b3/projects.locations.flexTemplates/launch#FlexTemplateRuntimeEnvironment)\n(Flex templates) or\n[`RuntimeEnvironment`](/dataflow/docs/reference/rest/v1b3/RuntimeEnvironment)\n(classic templates) object. \n\n {\n additionalExperiments : [\"streaming_mode_at_least_once\"]\n ...\n }\n\n### Custom templates\n\nIf you create a custom template that supports at-least-once processing, add the\nfollowing top-level fields to the template metadata file: \n\n {\n \"streaming\": true,\n \"supportsAtLeastOnce\": true,\n \"supportsExactlyOnce\": true,\n \"defaultStreamingMode\": \"AT_LEAST_ONCE\"\n }\n\nThese metadata fields enable users to select the streaming mode when deploying\nthe template in the Google Cloud console. The `defaultStreamingMode` field\nis optional and specifies the default streaming mode for the template. If you\ndon't specify `defaultStreamingMode` and the template supports both modes, then\nexactly-once mode is the default.\n\nFor more information, see the following sections in the Dataflow\ntemplates documentation:\n\n- Flex templates: [Metadata](/dataflow/docs/guides/templates/configuring-flex-templates#metadata)\n- Classic templates: [Use metadata in your pipeline code](/dataflow/docs/guides/templates/creating-templates#use-metadata-in-your-pipeline-code)\n\nView a job's streaming mode\n---------------------------\n\nTo view the streaming mode for a job, go to the **Jobs** page in the\nGoogle Cloud console.\n\n[Go to Jobs](https://console.cloud.google.com/dataflow/jobs)\n\nThe streaming mode is also listed on the job details page, in the **Job\ninfo** panel.\n\nLimitations\n-----------\n\nAt-least-once streaming mode requires\n[Streaming Engine](/dataflow/docs/streaming-engine) with\n[resource-based billing](/dataflow/docs/streaming-engine#compute-unit-pricing).\n\nPricing\n-------\n\nAt-least-once mode always uses\n[resource-based billing](/dataflow/docs/streaming-engine#compute-unit-pricing),\nwhere you're billed for the total resources that are consumed by your job.\n\nThe per-unit cost of\n[Streaming Engine Compute Units](/dataflow/pricing#streaming-compute-units) is\nthe same regardless of the streaming mode. However, in most cases a pipeline\nconsumes significantly fewer total resources when using at-least-once mode.\n\nWhat's next\n-----------\n\n- Learn more about [exactly-once processing](/dataflow/docs/concepts/exactly-once)."]]