Understanding AWS Lambda Limits
Explore AWS Lambda Limits or quotas and optimize your serverless experience for enhanced performance.
AWS Lambda has transformed the developer landscape, providing a streamlined experience where developers can focus on function and code development without the burden of managing the underlying infrastructure. The Lambda compute service marks a pivotal shift in application architecture, underscoring the significance of incorporating AWS Lambda limits into the design of serverless applications. It is crucial to be mindful of these limits to ensure optimal performance and adherence to best practices in serverless architecture.
AWS imposes intentional restrictions, both soft and hard, establishing guardrails to encourage best practices in Lambda function design. Explore the boundaries of AWS Lambda, from memory and concurrency limits to function scalability and the nuances of AWS Lambda service and resource constraints. Additionally, understand how the AWS Lambda free tier comes with its own set of limitations. Effectively managing these AWS Lambda limits ensures optimal performance and reliability for your serverless architecture. Avoiding rate limits and navigating AWS Lambda hard limits are integral aspects of architecting resilient and efficient serverless applications. In this blog, discover strategies to optimize AWS Lambda functions within the defined limits while accommodating concurrent calls to AWS Lambda functions.
AWS Lambda Limits Overview
AWS Lambda Limits can be categorized to two: Soft Limit and Hard Limit.
Soft Limits are limits which AWS defined with a default values per region and in an account. These are limits which can be changed by a support ticket with AWS.
Hard limits are restrictions from the AWS for the Lambda service and this can't be changed. An example for hard limit is Lambda timeout which is set as 15min. If an application requires a processing time of more than 15min, then you should consider other compute services from AWS.
AWS Lambda Soft Limits
AWS Lambda soft limit mainly falls in to the Compute and storage section. Below is the list of the soft limits,
Resource | Limit |
---|---|
Concurrent executions | 1,000 |
Storage for uploaded functions (.zip file archives) and layers. Each function version and layer version consumes storage. | 75 GB |
Storage for functions defined as container images. These images are stored in Amazon ECR. | 10,000 images |
Elastic network interfaces per virtual private cloud (VPC) | 250 |
Concurrent executions: Understanding AWS Lambda Concurrency Limits
Unlike hosting an application in a server, AWS scales the Lambda execution automatically. When there is multiple requests for a given time and the Lambda execution environment cannot fulfill it, AWS automatically spins up more lambda instances for the concurrent execution. In order to limit the misuse of this concurrent execution, AWS has set a lambda concurrent limit of 1,000.
This lambda concurrent limit is configured at AWS account level and is applicable for all the lambda functions in the account. As mentioned above this limit is a soft lambda limit and can be increased to Tens of thousands with an AWS support ticket.
Storage for uploaded function as zip file, functions defined as container images and layers: Navigating AWS Lambda Function and Layer Storage Limits
When a lambda is deployed to AWS , AWS stores the function code with dependencies and is managed by the AWS. AWS also keep the code for every version and we can switch to version in Lambda if required. There is a soft limit kept for the storage of functions and layers packages as zip file and it is 75GB. This function storage limit can be increased Terabytes as per the AWS documentation
Similary for the lambda functions using the container image, ECR image limit is applicable. Each supported Region for ECR currently supports 10,000 images and it can be incresed.
Elastic network interfaces per virtual private cloud (VPC) Limit
By default, Lambda runs the functions in a secure VPC with access to AWS services and the internet. If the lambda requires access to private resources(eg: RDS DB) while the function is running, lambda can be connected to a VPC in the account. This is made possible by the ELastic network interfaces (ENI). When you connect a function to a VPC, Lambda assigns your function to a Hyperplane ENI (elastic network interface) for each subnet in your function's VPC configuration. Lambda creates a Hyperplane ENI the first time a unique subnet and security group combination is defined for a VPC-enabled function in an account. There is a total ENI limit of 250 within the AWS Account and this is shared with other resources like EFS. This aws lambda soft limit can be changed to thousands with a support ticket
AWS Lambda Hard Limits
AWS Lambda hard limits apply to function configuration, deployment, and execution. These are service level limits on the AWS Lambda service and can't be changed. Below is the list of the current hard limits,
Resource | Limit |
---|---|
Function memory allocation | 128 MB to 10,240 MB, in 1-MB increments |
Function timeout | 900 seconds (15 minutes) |
Function environment variables | 4 KB, for all environment variables associated with the function, in aggregate |
Function resource-based policy | 20 KB |
Function layers | five layers |
Function concurrency scaling limit | For each function, 1,000 execution environments every 10 seconds |
Invocation payload (request and response) | 6 MB each for request and response (synchronous) |
20 MB for each streamed response (Synchronous. The payload size for streamed responses can be increased from default values. Contact AWS Support to inquire further.) | |
256 KB (asynchronous) | |
Bandwidth for streamed responses | Uncapped for the first 6 MB of your function's response.For responses larger than 6 MB, 2MBps for the remainder of the response |
Deployment package (.zip file archive) size | 50 MB (zipped, for direct upload).250 MB (unzipped)This quota applies to all the files you upload, including layers and custom runtimes.3 MB (console editor). |
Container image settings size | 16 KB |
Container image code package size | 10 GB (maximum uncompressed image size, including all layers) |
Test events (console editor) | 10 |
/tmp directory storage | Between 512 MB and 10,240 MB, in 1-MB increments |
File descriptors | 1,024 |
Execution processes/threads | 1,024 |
Demystifying AWS Lambda Memory Limits
AWS Lambda has a memory limit that is configued by AWS. The AWS Lambda function can have a memory configuration between 128 MB to 10,240 MB and it can only be increased by 1-MB increments.
AWS Lambda Timeout Limit
AWS Lambda has an execution time limit of 15 mins (900 seconds). Incase the function execution wont be completed in 15mins, it is going to throw a timeout error.
AWS Lambda Payload Limit : Invocation Payload limit
AWS has kept the invocation payload limit to 6 MB for synchronous lambda invocation(eg:API gateway invocation of Lambda). This limit is appliccable for request and response. For Lambda functions that is used for response stream, the limit is 20mb and this can be changed with AWS support. For asynchronous lambda invocation the payload event limit is 256kb
AWS Lambda Deployment Package Size
FOr the Lambda function packages, there is hard limit of 50mb size for the zip files for direct upload and 250mb size for unzipped. This limit applies to all the files you upload, including layers and custom runtimes. For container based lambda functions, Container image code package size limit is 10 GB (maximum uncompressed image size, including all layers)
AWS Lambda API Limits
AWs Lambda API requests has the below limits
Resource | Limit |
---|---|
Invocation requests per function per Region (synchronous) | Each instance of your execution environment can serve up to 10 requests per second. In other words, the total invocation limit is 10 times your concurrency limit. |
Invocation requests per function per Region (asynchronous) | Each instance of your execution environment can serve an unlimited number of requests. In other words, the total invocation limit is based only on concurrency available to your function |
Invocation requests per function version or alias (requests per second) | 10 x allocated provisioned concurrency |
GetFunction API requests | 100 requests per second |
GetPolicy API requests | 15 requests per second |
Remainder of the control plane API requests (excludes invocation, GetFunction, and GetPolicy requests) | 15 requests per second |
Along with the AWS Lambda limits, while architecting a serverless application, it is important to understand the AWS Lambda Pricing.