Cloud Dataflow 任务中来自修改后的 Google 提供的模板的自动缩放性能问题

Auto-scaling performance issues in Cloud Dataflow task from modified Google-provided template

我开始使用 Google Cloud Dataflow,尝试启动一个批处理数据流水线来解析来自 Google Cloud Storage 的数亿条记录,并将结果保存到 BigQuery。查看文档,这个用例有一个完美的数据流模板,GCS_Text_to_BigQuery。我使用 Google (gs://dataflow-templates/latest/GCS_Text_to_BigQuery) 提供的这个模板的最新编译启动了一个任务,性能非常好(使用 n1-standard-16 机器的处理时间为 10-15 分钟) .

但是,该模板的编译是使用 BigQuery 的 WRITE_TRUNCATE 写入配置而不是所需的 WRITE_APPEND 生成的(4 月 13 日,此 Java 模板更新为此更改在其 GitHub 存储库中,但其更新的编译尚未在官方 GCS 存储桶中)。为了使用具有所需更改的模板,我在文档之后使用以下命令编译了更新的代码:

mvn compile exec:java \
-Dexec.mainClass=com.google.cloud.teleport.templates.TextIOToBigQuery \
-Dexec.cleanupDaemonThreads=false \
-Dexec.args=" \
--project=<gcp-project-id> \
--stagingLocation=gs://<gcs-bucket>/staging \
--tempLocation=gs://<gcs-bucket>/temp \
--templateLocation=gs://<gcs-bucket>/templates/text-io-to-bq.json \
--runner=DataflowRunner"

使用我自己编译的修改后的模板启动任务后,结果与使用 Google 提供的模板的结果大不相同:自动缩放似乎无法正常工作(任务期间工人的增加非常低,并且该过程永无止境,此外,工人的 % CPU 消耗非常低)。我正在使用 python API 启动任务,使用官方 Google 模板和我自己的模板具有完全相同的参数:

from googleapiclient.discovery import build

dataflow = build('dataflow', 'v1b3', cache_discovery=False)

# Compilation of template provided by Google (OK)
# dataflow_template = 'gs://dataflow-templates/latest/GCS_Text_to_BigQuery'

# Compilation of template build by me (NOK)
dataflow_template = 'gs://<gcs-bucket>/templates/text-io-to-bq.json'

parameters = {
    'javascriptTextTransformFunctionName': '<udf-function>',
    'JSONPath': 'gs://<gcs-bucket>/resources/schemas/<bq-schema-file>',
    'javascriptTextTransformGcsPath': 'gs://<gcs-bucket>/resources/UDF/<udf-file>',
    'inputFilePattern': 'gs://<gcs-bucket>/data/*',
    'outputTable': '<gcp-project>:<bq-dataset>.<bq-table>',
    'bigQueryLoadingTemporaryDirectory': 'gs://<gcs-bucket>/bq_temp_location/'
}

environment = {
    'tempLocation': 'gs://<gcs-bucket>/temp',
    'machineType': 'n1-standard-16'
}

request = dataflow.projects().locations().templates().launch(
    projectId='<gcp-project-id>',
    gcsPath=dataflow_template,
    location='<location>',
    body={
        'jobName': '<job-name>',
        'parameters': parameters,
        'environment': environment
    }
)

response = request.execute()

对于造成这种差异的原因有什么想法吗?非常感谢您的任何支持。提前致谢。

如评论中所述,您需要使用特定的 Java 版本才能编译您自己的模板。

在GitHubrepository中我们可以看到正确的版本是Java 8Maven 3