【发布时间】:2020-09-12 00:30:44
【问题描述】:
目前我们有一个数据流作业,它从 pubsub 读取并使用 FileIO.writeDynamic 将 avro 文件写入 GCS,当我们使用 10000 个事件/秒进行测试时,由于 WriteFiles/WriteShardedBundlesToTempFiles/GroupIntoShards 非常慢,因此无法更快地处理。下面是我们用来写的sn-p。 我们如何改进
PCollection<Event> windowedWrites = input.apply("Global Window", Window.<Event>into(new GlobalWindows())
.triggering(Repeatedly.forever(
AfterFirst.of(AfterPane.elementCountAtLeast(50000),
AfterProcessingTime.pastFirstElementInPane().plusDelayOf(DurationUtils
.parseDuration(windowDuration))))).discardingFiredPanes());
return windowedWrites
.apply("WriteToAvroGCS", FileIO.<EventDestination, Five9Event>writeDynamic()
.by(groupFn)
.via(outputFn, Contextful.fn(
new SinkFn()))
.withTempDirectory(avroTempDirectory)
.withDestinationCoder(destinationCoder)
.withNumShards(1).withNaming(namingFn));
我们使用 gs://tenantID 格式的自定义文件命名。/eventname/dddd-mm-dd/
【问题讨论】:
-
您指定 1 个分片有什么原因吗?
-
由于窗口逻辑指定50K,我们使用group by,不想随意生成更多文件
-
+1 Inigo 的评论,一个分片需要一个窗口的所有值都被洗牌到一个线程。
标签: java java-8 apache-beam google-dataflow