AWS Lambda设备上没有剩余空间错误 [英] AWS Lambda No Space Left on Device error
问题描述
我正在使用API网关调用lambda函数,该函数从s3导入mpeg文件(10 mb)并保存在lambda的/tmp文件夹中,然后lambda将其上传到外部API(youtube等) 最近,对lambda的API网关调用间歇性地失败,并显示错误
I am using API gateway to call lambda function that imports a mpeg file (10 mb) from s3 and saves in /tmp folder of lambda and the lambda uploads it to external API (youtube etc) Recently the API gateway call to lambda is failing intermittently with error
[Errno 28] No space left on device
这是我下载文件的方式
urllib.urlretrieve (s3_mpeg_url, '/tmp/{}'.format(mpeg_filename))
如果我创建了相同的lambda函数的新版本并分配给指向的别名API网关,它将开始工作,并在某个时刻再次出现相同的错误
If i create a new version of that same lambda function and assign to alias API gateway pointing to , it starts to work and again at some point it keeps getting the same error
当我从lambda控制台测试该lambda函数时,它始终有效
When i test that lambda function from lambda console it always works
有什么主意吗?
推荐答案
您的lambda函数大约有500MB /tmp
上可用的磁盘空间.但是,出于性能原因,AWS Lambda可能会在后续调用中保留并重用您的函数实例.您可以在此处采取两种可能的路径:
Your lambda function has approximately 500MB of disk space available on /tmp
. However, for performance reasons, AWS Lambda might retain and reuse instances of your function on subsequent calls. There are two possible paths you can take here:
- 如果您的函数是完全无状态的(即,将
mpeg
文件上传到外部API后不需要),只需在上传后从/tmp
文件夹中删除它即可. - 如果需要保留数据,请考虑在处理后将其存储在其他介质上,例如S3或DynamoDB.
- If your function is totally stateless (i.e. you don't need the
mpeg
file after uploading it to the external API), just delete it from the/tmp
folder after the upload. - If you need to keep the data around, consider storing it on another media, like S3 or DynamoDB after processing.
这篇关于AWS Lambda设备上没有剩余空间错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!