简体   繁体   English

为什么使用 AWS Lambda 层与 AWS SAM 部署 package 时存在大小差异

[英]Why is there a size difference when using the AWS Lambda layers vs AWS SAM deployment package

I am working on a Lambda function that needs to import SciPy and pyarrow .我正在研究需要导入SciPy和 pyarrow 的pyarrow Since there is an official AWS layer that contains SciPy - AWSLambda-Python38-SciPy1x:14 it is used in the function.由于有一个官方 AWS 层包含SciPy - AWSLambda-Python38-SciPy1x:14 ,因此它在 function 中使用。 pyarrow is contained in awswrangler that was already created as a layer to use in one of the previously made Lambdas. pyarrow包含在awswrangler中,该层已经创建为一个层,以在以前制作的 Lambda 中使用。

AWS SAM is used to package and deploy the function. AWS SAM用于 package 和部署 function。 Now there is a pretty interesting difference between copying the contents of the awswrangler layer to the deployment package directory which can be deployed and executed correctly and when both SciPy and awswrangler layers are used in the function.现在,将awswrangler层的内容复制到可以正确部署和执行的部署 package 目录与在 ZC1C41145268E618394D 中同时使用SciPyawswrangler层之间存在一个非常有趣的区别。 If both layers are used, executing sam deploy gives the following error:如果两个层都使用,执行sam deploy会出现以下错误:

Layers consume more than the available size of 262144000 bytes (Service: AWSLambdaInternal; Status Code: 400; ...

One thing to note is that when awswrangler layer contents are copied to the deployment package, there is no overlap with the existing contents, so the deployment package is not smaller because fe it already contains some of the packages that awswrangler uses.需要注意的一点是,当awswrangler层内容复制到部署 package 时,与现有内容没有重叠,因此部署 package 不会更小,因为它已经包含awswrangler使用的一些包。

the deployment package size (unzipped) needs to be <250 MB ( https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html ).部署 package 大小(解压缩)需要 <250 MB( https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.ZFC35FDC78A8A8228 Adding both layers results in 262 MB which is over the limit.添加这两个层会导致 262 MB 超出限制。

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

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