内存是如何分配给 Google Cloud 函数的? [英] How is memory allocated to a Google Cloud Function?

查看:20
本文介绍了内存是如何分配给 Google Cloud 函数的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天我在云功能中遇到了这个错误:

Today I got this error in cloud function:

函数被杀死.错误:超出内存限制

Function killed. Error: memory limit exceeded

我的函数基于 authenticated-json-api 示例 的 Firebase 示例函数.因为它的工作原理很吸引人,所以我用多个路由和多个任务对其进行了扩展,例如连接多个外部 api、将 base64 字符串转换为 pdf 以进行存储、验证、日志记录等......

My function is based on authenticated-json-api example of Firebase sample functions. Because it worked like a charm, I extended it with multiple routes and multiple tasks like connecting with multiple external api, turning base64 strings into pdf on storage, validation, logging, and so on...

我删除了一些路线,现在看起来更稳定了.我现在的问题是:单个函数中的代码/处理量是否有限制.将它们拆分为多个 express api 会更好吗?

I removed some routes and it looks more stable now. My question now is: Can there be a limit to the amount of code / processing there can be within a single function. And would it be a better approach to split them up in multiple express api's ?

我还发现了一些关于为特定函数分配内存的问题.但是,我在 Google Cloud Platform 中找不到更改它的选项,也找不到 firebase package.json 中的选项来设置它.

I also found some questions about allocating memory to specific functions. However, I can't find the option in Google Cloud Platform to change it nor the option in firebase package.json to set it.

推荐答案

我找到了解决方案:

  1. 转到 Google Cloud Platform Console(不是 Firebase 控制台)
  2. 在菜单中选择云函数
  3. 现在您可以在此处看到您的 firebase 函数(如果正确).否则检查您是否选择了正确的项目.
  4. 忽略所有复选框、按钮和菜单项,只需点击函数名称.
  5. 点击编辑(顶部菜单),只更改分配的内存并点击保存.

问候,彼得

这篇关于内存是如何分配给 Google Cloud 函数的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆