AWS Lambda Limits
Lambda limits can be found on the service quota page
Soft limits
Concurrency
When invoking Lambda a container is started. You'd never see this but it is what executes the function.
After executing the function, the container exists for a short time. Each of these containers can execute one request.
There is a limit on the number of these containers running at once (10 or so).
Contact AWS Support for an increase in this
Storage
This applies to both the function and code in Lambda Layers
The soft limit in this respect is 75GB.
Contact AWS Support for an increase in this
Elastic Network Interfaces
This only applies to functions attached to a VPC.
This is needed to communicate with other resources, either internal or external
Realistically, this is unlikely to be hit due to the existence of AWS Hyperplane
Contact AWS Support for an increase in this
Hard limits
Execution Time
The maximum execution time is 15 minutes. AWS force stop any running functions at that stage
A common approach is to split tasks into smaller tasks. Lambda is great at running workloads in parallel.
Memory and CPU Constraints
When configuring Lambda, only the memory can be configured, the vCPU is relative to the memory allocation. The max is 10GB
Either optimise your code or split high memory tasks into smaller tasks.
领英推荐
Storage
Storage for Lambda is ephemeral and stored in /tmp.
The default storage size is 512MB and can be increased up to 10GB. Increasing this will increase the cost by increasing the charge per second.
Mitigate this by storing data in S3 or EFS. EFS requires the Lambda function to be connected to a VPC. Both of these options will increase cold starts.
Cold starts
I mentioned earlier about a container being started in the background to initiate the Lambda function. Each time one of these is started, this is referred to as a cold start.
These are regularly killed off by AWS to free resources, obviously these are running on servers and server space is limited.
Provisioned concurrency keeps a configured number of these running so there are no cold starts but these are charged.
Function size
Unzipped code has a limit of 250MB. This includes all layers.
The only mitigations here are limiting dependencies to those absolutely necessary and splitting functions.
Language support
Lambda supports many languages. A full list is here
It is possible to build and run your own runtime, the walkthrough is here
Network Limits
Lambda cannot have a static IP address and establishing rules to restrict outbound traffic isn't so easy. The only approach here is attaching the Lambda to a VPC and route traffic via a NAT Gateway or proxying outbound traffic.
Debugging
Running Lmabda locally isn't natively an easy task. You may wish to check out localstack for some support on this.
Another approach is to use the SST framework to debug code locally, other methods through SST include establishing a web socket directly to your Lambda.