brefphp / bref

Serverless PHP on AWS Lambda
https://bref.sh
MIT License
3.14k stars 364 forks source link

Vendor folder size limit #689

Closed aluferraz closed 3 years ago

aluferraz commented 4 years ago

Hi there,

I have a lot of composer dependencies in my API, which makes the vendor folder quite big (around 1gb)

When I try to deploy my application I receive the following error:

WebsiteLambdaFunction - Unzipped size must be smaller than 147391822 bytes

Is there workaround on that ?

mnapoli commented 4 years ago

Hi, did you remove the development dependencies before deploying? Also make sure the dependencies are not installed from source (git). 1gb is huge indeed.

It might be worth looking into that directory.

See #254

aluferraz commented 4 years ago

Hi there,

Thanks a lot for your support ! I've created a vanilla Lumen project and the vendor folder has ~500mb (even installing with --no-dev).

Here is my config.json.

I see that now lambda supports EFS disks attached to it, maybe we could load the vendor folder from an EFS disk?

"name": "laravel/lumen", "description": "The Laravel Lumen Framework.", "keywords": ["framework", "laravel", "lumen"], "license": "MIT", "type": "project", "require": { "php": "^7.2.5", "bref/bref": "^0.5.29", "laravel/lumen-framework": "^7.0" }, "require-dev": { "fzaninotto/faker": "^1.9.1", "mockery/mockery": "^1.3.1", "phpunit/phpunit": "^8.5" }, "autoload": { "classmap": [ "database/seeds", "database/factories" ], "psr-4": { "App\\": "app/" } }, "autoload-dev": { "classmap": [ "tests/" ] }, "config": { "preferred-install": "dist", "sort-packages": true, "optimize-autoloader": true }, "minimum-stability": "dev", "prefer-stable": true, "scripts": { "post-root-package-install": [ "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" ] } }

aluferraz commented 4 years ago

https://aws.amazon.com/pt/about-aws/whats-new/2020/06/aws-lambda-support-for-amazon-elastic-file-system-now-generally-/?sc_channel=em&sc_campaign=GLOBAL_CT_NL_global-snapshot-newsletter_20200624_&sc_medium=em_264814&sc_content=PA_nl_la&sc_geo=mult&sc_country=global&sc_outcome=pa&trk=em_264814&mkt_tok=eyJpIjoiWlRZM05tTTFZekF5WTJJNCIsInQiOiJ2NzM0N0hSUm9jZXhkVUxnaGZBUjExeGFTeVUraUg3ak01RzNYSUZuWjhoY2RXamJhZTdPMVVNOW9DNHpYZjhKNmYydVhLXC9sT0hqRjZBeXJXTFJXemFTcGF3aVR4dks0RFNYak1mVDVyeDNkeVwvZ3pWTmNBU3B2T3FIaG1GbXk5QVdGbE1jdnhPRzhYOVQxQ01YVm9Ldz09In0%3D

mnapoli commented 4 years ago

the vendor folder has ~500mb

That sounds very wrong. If you installed with --no-dev then it may be that part posing the problem:

Also make sure the dependencies are not installed from source (git).

EFS is not fast enough (at the moment) to serve that many small files: https://www.youtube.com/watch?v=yJD7AQgfEJ8