google-cloud-platform - 从同一模板启动多个 Dataflow 作业时,如何避免“IN_USED_ADDRESSES”错误?
问题描述
我创建了一个 Dataflow 模板,它允许我将 Cloud Storage 中的 CSV 文件中的数据导入 BigQuery。我每天在特定时间使用 Cloud Function for Firebase 从这个模板创建工作。这是函数中的代码(删除了一些不相关的部分)。
const filePath = object.name?.replace(".csv", "");
// Exit function if file changes are in temporary or staging folder
if (
filePath?.includes("staging") ||
filePath?.includes("temp") ||
filePath?.includes("templates")
)
return;
const dataflow = google.dataflow("v1b3");
const auth = await google.auth.getClient({
scopes: ["https://www.googleapis.com/auth/cloud-platform"],
});
let request = {
auth,
projectId: process.env.GCLOUD_PROJECT,
location: "asia-east1",
gcsPath: "gs://my_project_bucket/templates/csv_to_bq",
requestBody: {
jobName: `csv-to-bq-${filePath?.replace(/\//g, "-")}`,
environment: {
tempLocation: "gs://my_project_bucket/temp",
},
parameters: {
input: `gs://my_project_bucket/${object.name}`,
output: biqQueryOutput,
},
},
};
return dataflow.projects.locations.templates.launch(request);
每次在 Cloud Storage 中写入任何文件时都会触发此功能。我正在使用传感器,所以至少我必须在 15 分钟内导入 89 个不同的数据,即不同的 CSV 文件。
如果同时只有 4 个工作,则整个过程运行良好。但是,当函数尝试创建第五个作业时,API 返回了许多不同类型的错误。
错误1(不准确,因为我再也找不到错误了):
Error Response: [400] The following quotas were exceeded: IN_USE_ADDRESSES
错误2:
Dataflow quota error for jobs-per-project quota. Project *** is running 25 jobs.
Please check the quota usage via GCP Console.
If it exceeds the limit, please wait for a workflow to finish or contact Google Cloud Support to request an increase in quota.
If it does not, contact Google Cloud Support.
错误 3:
Quota exceeded for quota metric 'Job template requests' and limit 'Job template requests per minute per user' of service 'dataflow.googleapis.com' for consumer 'project_number:****'.
我知道我可以间隔开开始工作以避免错误 2 和 3。但是,我不知道如何以不会填满地址的方式开始工作。那么,我该如何避免呢?如果我不能,那么我应该使用什么方法?
解决方案
我在这里的另一篇文章中回答了这个问题 -需要更新哪些 Compute Engine 配额才能使用 50 个工作人员(IN_USE_ADDRESSES、CPUS、CPUS_ALL_REGIONS ..)运行 Dataflow?.
让我知道这是否有帮助。
推荐阅读
- python - 当我尝试取消缩放和取消缩放 X 和 y 数组时遇到问题
- node.js - 想知道如何在嵌入的命令中显示添加的角色
- json - 将 JSON 反序列化为表
- docker - 使用 Delve 和 Docker 调试 Go API - 无法使用 Postman 访问 API
- css - 如果表格太小,如何仅设置第一列以填充剩余空间或修剪其内容?
- javascript - JQuery UI 选项卡在 Magento 2 上的 IE11 中不起作用
- go - 使用 Kubernetes go-client 向 Pod 添加标签的最短方法是什么
- mysql - SQL if 存在更新数量
- java - 如何使用 JPA 将 DELETE 和 SELECT 语句作为一个查询执行?
- oracle - 如何将 Oracle 序列更新/增加一千万?