We are using Vapor to deploy our Laravel App to AWS Lambda.
After small change (10 lines were introduced), the deploy process via GitHub action fails with the following message:
Message: Your application exceeds the maximum size allowed by AWS Lambda.
Now we can not deploy to this env (develop). All other branches (staging, production) are fine and we can use them.
No new libraries or any big changes were introduced between the last deploy.
Deploy via Vapor CLI also fails with the same message.
Any ideas where we can search for the source of the problem?
Technical Limitations The maximum time a function can run is 15 minutes, and the default timeout is 3 seconds. Obviously, this makes Lambda unsuitable for long-running workloads. The payload for each invocation of a Lambda function is limited to 6MB, and memory is limited to just under 3GB.
One of the simpler workarounds is to move the large file into Cloud Storage like S3. During the lambda runtime, download the file and continue the processing as required. In this example, we can move the mock_data. csv to S3, and update the handler function to download the file from S3 before everything else.
Since your code is stateless, AWS Lambda can start as many copies of your function as needed without lengthy deployment and configuration delays. There are no fundamental limits to scaling a function. AWS Lambda will dynamically allocate capacity to match the rate of incoming events.
Lambda deployment packages have a size limit of 50 MB. The deployment package of your dev branch is crossing that limit. That's why you get the error Your application exceeds the maximum size allowed by AWS Lambda.
If reducing the size of your deployment package is not an option, upload the package to S3 & provide the S3 URL to the Lambda function. The deployment package is allowed to have a max size of 250 MB (uncompressed) when you go the S3 route.
See my blog post for more details!
You can switch to a Docker Runtime. Docker deploys can be up to 10GB.
First foreach environment, create a Docker file with the name <environment>.Dockerfile
, for example production.Dockerfile
for the production environment.
Then in that file put:
FROM laravelphp/vapor:php81
COPY . /var/task
Then change the "runtime" for each environment in vapor.yml to "docker".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With