超过了Google Cloud Functions内存限制 [英] Google Cloud Functions memory limit exceeded

查看:86
本文介绍了超过了Google Cloud Functions内存限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用NodeJS和Sharp(libvips)库在Google Cloud Functions中进行了大量图像处理.即使我们将函数的内存限制设置为2Gb,该函数偶尔也会用完内存并崩溃,并显示错误:超出了内存限制".函数调用被中断."信息.

We do a lot of image processing in Google Cloud Functions using NodeJS and Sharp (libvips) library. Even though we have the memory limit for our functions set to 2Gb the function occasionally runs out of memory and crashes with the 'Error: memory limit exceeded. Function invocation was interrupted.' message.

是否有办法捕获此异常?我想返回更礼貌的(json)响应,以便我的服务器知道问题出在哪里.

Is there a way to catch this exception? I want to return a more polite (json) response so my server knows what the problem was.

推荐答案

NodeJS中应用程序范围内未捕获的异常必须为手动报告.

Application-wide uncaught exceptions in NodeJS Google Cloud Platform apps need to be reported manually.

话虽这么说,有关内存限制超出错误的更多详细信息可能已经在日志中了.您只需要从GCP控制台在日志查看器中搜索错误消息,如文档,或使用高级过滤器,例如按时间搜索.该文档还说明了如何从您的Cloud Functions中写入日志条目.然后,您可以使用Stackdriver Logging API,例如,导出日志并获取一个json.

That being said, more details on the memory limit exceeded error could already be on the logs. You only need to search the error message on the Logs viewer from the GCP console as shown in the docs, or use Advanced Filters e.g. to search by time. The documentation also explains how to write log entries from your Cloud Functions. Then you can use the Stackdriver Logging API, for instance, to export the logs and get a json.

我还建议使用Stackdriver Monitoring来跟踪内存使用情况您的Cloud Function.

I would also suggest using Stackdriver Monitoring to track the memory usage of your Cloud Function.

这篇关于超过了Google Cloud Functions内存限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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