Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Serverless | Code storage limit exceeded

I have an error Code storage limit exceeded deploy the serverless application in AWS. Total size 409 B.

The error message says:

An error occurred: HelloLambdaFunction - Code storage limit exceeded. (Service: AWSLambda; Status Code: 400; Error Code: CodeStorageExceededException; Request ID: ...)

like image 838
Ashish Kadam Avatar asked Aug 07 '18 08:08

Ashish Kadam


People also ask

Does AWS Lambda have a limit?

There is a hard limit of 6mb when it comes to AWS Lambda payload size. This means we cannot send more than 6mb of data to AWS Lambda in a single request. Developers will typically run into this limit if their application was using AWS Lambda as the middle man between their client and their AWS S3 asset storage.

How much disk space can AWS Lambda use?

Today, we are announcing that AWS Lambda now allows you to configure ephemeral storage ( /tmp ) between 512 MB and 10,240 MB.

Can we increase Lambda payload size?

Function configuration, deployment, and executionThey cannot be changed. The Lambda documentation, log messages, and console use the abbreviation MB (rather than MiB) to refer to 1024 KB. 128 MB to 10,240 MB, in 1-MB increments. This quota applies to all the files you upload, including layers and custom runtimes.

How much TPS can Lambda handle?

With increased concurrent execution limit, there is still one more limit the Burst Concurrency limit. This will limit lambda to serve only 3000 concurrent request at time. If it receives more than 3000 concurrent requests some of them will be throttled until lambda scales by 500 per minute.


2 Answers

Looking specifically for this problem related to serverless, I found https://github.com/serverless/serverless/issues/400. It is a known problem of the serverless framework. However, some enterprising individual created a solution to the problem with a plugin that is able to prune old versions: https://github.com/claygregory/serverless-prune-plugin. This allows you to clean up the old versions and code storage without deleting the entire stack.

For example, you can delete all but the last 10 versions using:

sls prune -n 10 

There are further options for restricting by stage or region. Even better it is possible to integrate the plugin into the deploy to automatically remove all but x versions.

I used this plugin for my current serverless project and it delivered on the promise.

like image 176
Corin Avatar answered Oct 17 '22 06:10

Corin


From PublishVersion - AWS Lambda, CodeStorageExceededException means:

You have exceeded your maximum total code size per account.

From AWS Lambda Limits - AWS Lambda:

  • Total size of all the deployment packages that can be uploaded per region: 75 GB
  • Lambda function deployment package size (compressed .zip/.jar file): 50 MB
  • Size of code/dependencies that you can zip into a deployment package (uncompressed .zip/.jar size): 250 MB
  • Total size of environment variables set: 4 KB
like image 38
John Rotenstein Avatar answered Oct 17 '22 04:10

John Rotenstein