AWS Lambda ENI limitation in VPC clarification

风格不统一 提交于 2019-12-24 03:35:09

问题


I found this in the AWS official docs for lambda:

If your Lambda function accesses a VPC, you must make sure that your VPC has sufficient ENI capacity to support the scale requirements of your Lambda function. You can use the following formula to approximately determine the ENI requirements.

Projected peak concurrent executions * (Memory in GB / 3GB)

I understand the reason behind this formula. My only question is: why 3GB? From where this number comes from?


回答1:


The formula Projected peak concurrent executions × (Memory in GB / 3GB) is a proxy for the answer to the actual (but unspoken) question "How many m-class (general purpose) EC2 instances will Lambda need to allocate in order to accommodate the required number of containers of this size?"

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.

https://docs.aws.amazon.com/lambda/latest/dg/resource-model.html

The ratio is "the same" because the M3... or something very similar to it... is what Lambda is actually using, under the hood, to host your containers.

The m3.medium is the smallest machine of the m3 family and has 3.75GB of RAM... so the number of this type of EC2 VM that lambda will need to provision -- and thus the number of ENIs that will be needed -- is approximately n × (m / 3GB). This instance could host (e.g.) approximately 2 × 1.5 GB or 24 × 128 MB or 1 × 3.0 GB containers, leaving some room for operational/management overhead within the VM.

How much overhead may be involved, and the algorithm Lambda uses when placing and selecting containers, and whether Lambda uses a mix of instance sizes and under what rules... are all part of the Lambda black box. Logic would dictate that Lambda would start with smaller instances and progress to larger ones as concurrency grows, since the larger instances (within the same family) would allow more packing efficiency without a performance penalty (since memory and CPU are dedicated, in a fixed ratio, to each container), particularly for large and oddly-sized containers. What this formula reveals that it is not containers that receive ENIs but rather instances... and there will be approximately n × (m / 3GB) instances allocated by Lambda under concurrency n of size m GB.




回答2:


3GB is the max memory allocation for a single lambda function. https://docs.aws.amazon.com/lambda/latest/dg/limits.html



来源:https://stackoverflow.com/questions/54763625/aws-lambda-eni-limitation-in-vpc-clarification

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!