简体   繁体   English

如何将 AWS Lambda 中的 /tmp 文件夹更改为 efs

[英]How to change the /tmp folder in AWS Lambda to efs

I'm using aws lambda as a compiler for C++ Code, I'm sending to it c++ code, the lambda compiles and runs it using local g++ and returns the output back. I'm using aws lambda as a compiler for C++ Code, I'm sending to it c++ code, the lambda compiles and runs it using local g++ and returns the output back.

I recently had too many concurrent requests that the /tmp directory of the lambda instance was too big (>512mb) and I got the following error: No space left on device我最近有太多并发请求,lambda 实例的 /tmp 目录太大(>512mb),我收到以下错误:设备上没有剩余空间

I use efs with the lambda, and I want the /tmp directory of the lambda to be in the efs instead in the instance of the lambda.我将 efs 与 lambda 一起使用,并且我希望 lambda 的 /tmp 目录位于 efs 中,而不是 lambda 的实例中。

I'm using lambda with Docker image.我正在使用 lambda 和 Docker 图像。 How can I change the instance path of the tmp directory of the lambda to a directory in the efs?如何将lambda的tmp目录的实例路径更改为efs中的目录?

Thank You!谢谢你!

First you need to create an EFS file system.首先,您需要创建一个 EFS 文件系统。 Then:然后:

  1. Navigate to the Lambda console and select your function from the list.从列表中导航到 Lambda 控制台和 select 您的 function。
  2. Scroll down to the File system panel, and choose Add file system.向下滚动到文件系统面板,然后选择添加文件系统。
  3. In the File system configuration:在文件系统配置中:
  • From the EFS file system dropdown, select the required file system.从 EFS 文件系统下拉列表中,select 是所需的文件系统。 From the Access point dropdown, choose the required EFS access point.从接入点下拉列表中,选择所需的 EFS 接入点。
  • In the Local mount path, enter the path your Lambda function uses to access this resource.在本地安装路径中,输入您的 Lambda function 用于访问此资源的路径。 Enter an absolute path.输入绝对路径。
  • Choose Save.选择保存。

Source: https://aws.amazon.com/blogs/compute/using-amazon-efs-for-aws-lambda-in-your-serverless-applications/资料来源: https://aws.amazon.com/blogs/compute/using-amazon-efs-for-aws-lambda-in-your-serverless-applications/

Since you are already using ephemeral storage go 512 mb, just increase the size to your desired size ( ofcourse this will take some hit and trials to determine depending on your workload and number of requests) as there is no dynamic scaling option of ephemeral storage, + you need to consider cost too.由于您已经在使用临时存储 go 512 mb,因此只需将大小增加到您想要的大小(当然,这需要根据您的工作负载和请求数量来确定),因为临时存储没有动态扩展选项, + 你也需要考虑成本。

You will find settings for ephemeral storage in general configuration ( aws console )您将在常规配置(aws 控制台)中找到临时存储的设置

Note :- If you want to use persistence storage and share that storage among all invocations of LAbda then go for EFS, but if speed matters to you it is faster than EFS注意:- 如果您想使用持久性存储并在所有 LAbda 调用中共享该存储,则 EFS 为 go,但如果速度对您很重要,它比 EFS 快

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM