如何在Google Cloud Run中增加内存限制?

6

我正在使用Cloud Run + Cloud Firestore构建一个简单的基于Flask的应用程序。有一个方法会带来大量数据,日志显示了以下错误:

`Memory limit of 244M exceeded with 248M used. Consider increasing the memory limit, see https://cloud.google.com/run/docs/configuring/memory-limits`

我该如何在cloudbuild.yaml中增加内存限制?我们的YAML文件包含以下内容:

# cloudbuild.yaml
steps:
  # build & push the container image
- name: "gcr.io/kaniko-project/executor:latest"
  args: ["--cache=true", "--cache-ttl=48h", "--destination=gcr.io/$PROJECT_ID/todo:latest"]
  # Deploy container image to Cloud Run
- name: "gcr.io/cloud-builders/gcloud"
  args: ['beta', 'run', 'deploy', 'todo', '--image', 'gcr.io/$PROJECT_ID/todo:latest', '--region', 'us-central1', '--allow-unauthenticated', '--platform', 'managed']

谢谢你

1个回答

14
在最后一步的参数中,加入'--memory', '512Mi' 大小的格式为一个定点或浮点数,接着是一个单位:G、M 或 K 分别对应千兆字节、兆字节或千字节,或者使用二进制的等效单位: Gi、Mi 或 Ki 分别对应吉比字节、兆比字节或千比字节。

感谢 steren 和 @wietse-venema。 - marcosluis2186
为了使用大内存,您需要使用“--cpu”“num-cpus”更改CPU数量。[https://cloud.google.com/run/docs/configuring/memory-limits] - Jonatas Eduardo
请注意,gcloud deploy run 的参考文档在此处:https://cloud.google.com/sdk/gcloud/reference/run/deploy。 - masaya

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接