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

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

问题描述

今天我在云函数中遇到此错误:

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控制台(不是Firebase控制台)
  2. 在菜单中选择 Cloud Functions
  3. 现在,如果正确,您将在此处看到您的firebase函数.否则,请检查您是否选择了正确的项目.
  4. 忽略所有复选框,按钮和菜单项,只需单击功能名称.
  5. 单击编辑"(顶部菜单),仅更改分配的内存,然后单击保存".
  1. Go to the Google Cloud Platform Console (not the Firebase console)
  2. Select Cloud Functions in the menu
  3. Now you see your firebase function in here if it's correct. Otherwise check if you selected the right project.
  4. Ignore all checkboxes, buttons and menu items, just click on the name of the function.
  5. Click on edit (top menu) and only change the allocated memory and click save.

关于彼得

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

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