在 DataflowRunner 中,EnforceRampUp 用于控制计算资源的跃升,即根据数据流的负载和计算资源的状况来逐渐增加并发执行的工作数量。禁用此选项后,始终使用任务的最大并发度。
对于 DataStore 的写入,EnforceRampUp 可以导致每个任务以低于预期的速率执行,从而增加总任务时间,并可能导致资源的浪费。
因此,建议将 --experiments=disable_slow_start=true 添加到 DataflowPipelineOptions 的选项中,以禁用慢启动并在任务启动时立即使用最大并发度。这会大大减少写入到 DataStore 的任务所需的总时间。
示例代码:
from apache_beam.options.pipeline_options import PipelineOptions
from apache_beam.options.pipeline_options import GoogleCloudOptions
from apache_beam.options.pipeline_options import StandardOptions
from apache_beam.options.pipeline_options import WorkerOptions
options = PipelineOptions()
google_cloud_options = options.view_as(GoogleCloudOptions)
google_cloud_options.project = 'my_project'
google_cloud_options.region = 'us-central1'
google_cloud_options.job_name = 'my_job_name'
worker_options = options.view_as(WorkerOptions)
worker_options.disk_size_gb = 100
worker_options.autoscaling_algorithm = 'NONE'
standard_options = options.view_as(StandardOptions)
standard_options.runner = 'DataflowRunner'
experimental_options = options.view_as(ExperimentalOptions)
experimental_options.add_experiment("disable_slow_start=true")
上一篇:ApacheBeam错误信息“无匹配签名的运算符=',参数类型为DATE和INT64。支持的签名:ANY=ANY。”
下一篇:ApacheBeamDataflow作业出现“TypeError:无法确定编码<TableReference>,请提供类型提示”