我有几个Python脚本,我想安排每月在Google cloud上运行一次。这些脚本主要触发DLP作业,将数据目录信息提取到GCS中的文件中。这些批处理工作负载几乎不会运行30分钟。所以我不需要使用像GKE,composer等非常耗费资源的服务。
对于这些批处理工作负载,我想知道GCP中可用的最佳选项。查看我在下面找到的一些博客文章使用Cloud Scheduler-> Cloud Functions ->创建VM (使用启动脚本)。https://medium.com/google-cloud/running-a-serverless-batch-workload-on-gcp-with-cloud-scheduler-cloud-functions-and-compute-86c2bd573f25
我对上面的设计有以下问题..1)云函数启动虚拟机需要运行多长时间?我知道云函数的超时时间是9分钟,如果虚拟机处理启动脚本的时间超过9分钟,会发生..what吗?
任何其他的设计想法都是非常感谢的。
谢谢
发布于 2020-05-13 05:00:09
我是那个medium帖子的作者。
1)云函数启动虚拟机需要运行多长时间?您可以将云函数代码更改为不等待响应,它使用的是NodeJS,因此您不必等待Promise。同样,在该解决方案中,Cloud Function作业仅用于触发VM创建。
.createVM(vmName, vmConfig)
.then(data => {
// Operation pending.
const vm = data[0];
const operation = data[1];
console.log(`VM being created: ${vm.id}`);
console.log(`Operation info: ${operation.id}`);
return operation.promise();
// This will return right away with the VM pending state, you can finish
// your logic here, and not wait for VM creation to finish.
// You can even ignore this step if you don't need the VM ID logged for
// debugging purposes
})
.then(() => {
const message = 'VM created with success, Cloud Function finished execution.';
console.log(message);
}使用相同的代码,在最坏的情况下(如果超过9分钟),云函数将超时,但VM创建将继续。
发布于 2020-03-12 18:07:07
https://stackoverflow.com/questions/60610003
复制相似问题