amazon-web-services - 为什么 Lambda 函数在使用 1536 MB 时执行速度要快得多?

标签 amazon-web-services aws-lambda

我有一个问题,我很想得到答案。

我有一个 Lambda 函数,它使用的最大内存为 31 MB 配置的分配内存为 128MB,需要 2556.68 毫秒。

但是,当将分配的内存增加到最大值时 1536 MB 完全执行只需要 621.81 ms,使用的 MAX 内存完全相同,为 31 MB。

为什么在两种情况下使用的内存完全相同时,Lambda 函数执行得更快?

最佳答案

这是因为分配给您的容器的 CPU 数量与您要求的内存数量成正比。

AWS Lambda allocates CPU power proportional to the memory by using the same ratio as a general purpose Amazon EC2 instance type, such as an M3 type. For example, if you allocate 256 MB memory, your Lambda function will receive twice the CPU share than if you allocated only 128 MB.

http://docs.aws.amazon.com/lambda/latest/dg/lambda-introduction-function.html



M3 实例每 30 GB RAM 具有 8 个 Xeon E5-2670 或 Xeon E5-2670 V2 超线程,因此按照这个比例,如果使用 1.5GB 内存,您将拥有大约 1.5 × (8 ÷ 30) × 2.6 GHz ≅ 1 GHz 的 CPU .在 128 MB 时,您只有大约 1/12。

关于amazon-web-services - 为什么 Lambda 函数在使用 1536 MB 时执行速度要快得多?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47256148/

相关文章:

mysql - Lambda NodeJS MySQL 任务超时

python - API Gateway 中的 AWS Lambda 集成响应 - {"message": "Internal server error"}

java - 在 AWS Lambda 控制台中的何处可以找到从 AWS Toolkit for Lambda 上传的 Java 代码

node.js - 如何使用 node.js 从 `AWS dynamodb` 获取/扫描所有项目

amazon-web-services - 从 Lambda 代码调用 AWS boto 函数

amazon-dynamodb - 如何在 AWS dynamodb 触发器函数中获取表名?

aws-lambda - 当我尝试使用方法 OPTIONS 进行 CORS 预检 (Lambda) 时,AWS cloudformation template.yaml 失败

amazon-web-services - AWS IAM 用户 - 限制 EC2 实例数量并限制 EBS 存储

amazon-web-services - cmake 文件中 cmake 命令的分号分隔列表

Apache2 开放式 SSL 证书显示在 AWS 负载均衡器上