amazon-web-services - AWS Lambda 是否在单独的 Firecracker VM 中运行每个调用?

标签 amazon-web-services aws-lambda firecracker

我了解 AWS Lambda 中的冷启动和热启动。

但是,我不确定在热启动期间,Lambda 架构是否在后端重用了 Firecracker 虚拟机?或者它是否在全新的虚拟机中进行调用?

有没有办法通过其他 AWS 解决方案对每次调用强制实现虚拟机级别隔离?

最佳答案

基于 Lambda execution context 文档中的说明,Lambda 尝试在后续执行之间重用执行上下文,这就是导致冷启动(当上下文启动时)和热启动(当重用现有上下文时)的原因。

You typically see this latency when a Lambda function is invoked for the first time or after it has been updated because AWS Lambda tries to reuse the execution context for subsequent invocations of the Lambda function.

Lambda Runtime Environment 文档中的另一项声明证实了这一点。其中指出:

When a Lambda function is invoked, the data plane allocates an execution environment to that function, or chooses an existing execution environment that has already been set up for that function, then runs the function code in that environment.

同一页面的后续段落提供了有关如何在同一 AWS 账户中的函数和执行之间共享环境/资源的更多信息:

Execution environments run on hardware virtualized virtual machines (microVMs). A microVM is dedicated to an AWS account, but can be reused by execution environments across functions within an account. [...] Execution environments are never shared across functions, and microVMs are never shared across AWS accounts.

enter image description here

此外,还有another doc page其中提供了有关环境之间隔离的更多详细信息,但同样没有提及每个环境强制执行 1 次的能力。

据我所知,没有办法让新的执行使用新的环境而不是现有的环境。 AWS 对此没有提供太多见解,但围绕该主题的措辞似乎表明大多数人实际上尝试做与您正在寻找的相反的事情:

When you write your Lambda function code, do not assume that AWS Lambda automatically reuses the execution context for subsequent function invocations. Other factors may dictate a need for AWS Lambda to create a new execution context, which can lead to unexpected results, such as database connection failures.

我想说,如果您关心的是与其他客户/帐户的隔离,AWS 通过虚拟化保证隔离,尽管不是在物理级别,但根据他们的 SLA 和您的 SLA/要求可能就足够了。相反,如果您正在考虑构建某种需要 Lambda 执行彼此隔离的 Multi-Tenancy 基础设施,那么该组件可能不是您想要的。

关于amazon-web-services - AWS Lambda 是否在单独的 Firecracker VM 中运行每个调用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63875600/

相关文章:

amazon-web-services - 如何比较 Amazon S3 对象的版本?

amazon-web-services - 使用 AWS Systems Session Manager 加密 CloudWatch LogGroups 的 KMS 权限

docker - 在 Docker 中运行 Firecracker

java - 定义一个采用映射中参数的方法

amazon-web-services - 默认 TransitGatewayRouteTable 的 TransitGatewayRouteTableId

ios - Cognito 身份未传递到 AWS Lambda 函数

linux - 为 AWS-Lambda : GLIBC issues 编译 pdftohtml 二进制文件

amazon-web-services - AWS Lambda (URL) 重写流程

linux - aws firecracker 如何处理 vcpu?