【发布时间】:2021-07-05 06:07:49
【问题描述】:
我正在使用 apache beam (GCP Dataflow) 和 python 构建管道,我的管道如下所示:
...
with beam.Pipeline(options=self.pipeline_options) as pipeline:
somepipeline = (
pipeline
| "ReadPubSubMessage" >> ReadFromPubSub(
subscription=self.custom_options.some_subscription)
| "Windowing" >> beam.WindowInto(beam.window.FixedWindows(30))
| "DecodePubSubMessage" >> beam.ParDo(DecodePubSubMessage()).with_outputs(ERROR_OUTPUT_NAME, main=MAIN_OUTPUT_NAME)
| "Geting and sorting listings" >> beam.ParDo(SortByCompletion())
| "Batching listings" >> beam.BatchElements(min_batch_size=3,max_batch_size=3)
| "Print logs" >> beam.Map(logging.info)
)
...
当我通过 DirectRunner 运行管道时,一切都按预期工作(您可以看到 1 个批次,其中包含 3 个元素):
但是当我使用 DataflowRunner 运行相同的代码时,我得到了这个结果(您可以看到 3 个批次,每个批次中有 1 个元素):
即使我并行运行此管道(在两个终端窗口中),也会发生这种情况。两者都使用流式标志运行。消息立即通过python脚本一一发送到pubsub。
问题: 什么会导致 DataflowRunner 出现这个问题(我的假设是数据流中的工作人员数量,但是当我检查它时,这项工作只有 1 个工作人员)以及如何获得与通过 DirrectRunner 相同的结果。
谢谢!
【问题讨论】:
标签: python google-cloud-dataflow pipeline batch-processing apache-beam