php
php copied to clipboard
Serverless Function maximum size limit of 50mb
Question
Hello, I was trying to deploy an old symfony 4.4.* project to vercel but sadly, I allways get a size limit error for the serverless function, I tried removing some dependencies but it seems I can't really tell how to work this around, if you have any suggestion :/.
[20:00:50.646] Running build in Washington, D.C., USA (East) – iad1
[20:00:50.708] Retrieving list of deployment files...
[20:00:51.283] Previous build caches not available
[20:00:52.268] Downloading 5680 deployment files...
[20:01:03.089] Running "vercel build"
[20:01:03.534] Vercel CLI 29.1.1
[20:01:04.042] > Installing Builder: [email protected]
[20:01:08.414] 🐘 Downloading user files
[20:01:08.414] 🐘 Downloading PHP runtime files
[20:01:08.417] 🐘 Installing Composer dependencies [START]
[20:01:08.691] [8.3MiB/0.12s] For additional security you should declare the allow-plugins config with a list of packages names that are allowed to run code. See https://getcomposer.org/allow-plugins
[20:01:08.692] [8.3MiB/0.12s] This warning will become an exception once you run composer update!
[20:01:08.732] [8.3MiB/0.16s] Installing dependencies from lock file
[20:01:08.733] [8.5MiB/0.16s] Verifying lock file contents can be installed on current platform.
[20:01:08.852] [10.2MiB/0.28s] Nothing to install, update or remove
[20:01:08.857] [10.1MiB/0.29s] Package symfony/debug is abandoned, you should avoid using it. Use symfony/error-handler instead.
[20:01:08.857] [10.1MiB/0.29s] Generating autoload files
[20:01:08.867] [11.1MiB/0.30s] composer/package-versions-deprecated: Generating version class...
[20:01:08.867] [11.1MiB/0.30s] composer/package-versions-deprecated: ...done generating version class
[20:01:08.874] [10.2MiB/0.30s] 58 packages you are using are looking for funding.
[20:01:08.874] [10.2MiB/0.30s] Use the `composer fund` command to find out more!
[20:01:08.874] [10.2MiB/0.30s]
[20:01:08.874] [10.2MiB/0.30s] Run composer recipes at any time to see the status of your Symfony recipes.
[20:01:08.874] [10.2MiB/0.30s]
[20:01:08.874] [10.2MiB/0.30s] Memory usage: 10.23MiB (peak: 11.16MiB), time: 0.3s
[20:01:08.886] 🐘 Installing Composer dependencies [DONE]
[20:01:09.405] 🐘 Creating lambda
[20:01:11.154] Build Completed in /vercel/output [3s]
[20:01:11.803] Deploying outputs...
[20:01:20.338] Failed to process build result for "api/index". Data: {"type":"Lambda"}.
[20:01:20.340] Error: The Serverless Function "api/index" is 73.09mb which exceeds the maximum size limit of 50mb. Learn More: https://vercel.link/serverless-function-size
[20:01:20.896] Deployment completed
[20:01:20.472] NOW_SANDBOX_WORKER_MAX_LAMBDA_SIZE: The Serverless Function "api/index" is 73.09mb which exceeds the maximum size limit of 50mb.
here is a list of my direct packages :
composer show --direct
Deprecation Notice: Using ${var} in strings is deprecated, use {$var} instead in phar:///usr/local/bin/composer/src/Composer/Autoload/AutoloadGenerator.php:869
Deprecation Notice: Using ${var} in strings is deprecated, use {$var} instead in phar:///usr/local/bin/composer/src/Composer/Autoload/AutoloadGenerator.php:874
composer/package-versions-deprecated 1.11.99.4 Composer plugin that provides efficient querying for installed package versions (no runtime IO)
doctrine/annotations 1.14.3 Docblock Annotations Parser
doctrine/doctrine-bundle 2.7.2 Symfony DoctrineBundle
doctrine/doctrine-migrations-bundle 3.2.2 Symfony DoctrineMigrationsBundle
doctrine/orm 2.15.0 Object-Relational-Mapper for PHP
symfony/asset v4.4.46 Manages URL generation and versioning of web assets such as CSS stylesheets, JavaScript files and image files
symfony/console v4.4.49 Eases the creation of beautiful and testable command line interfaces
symfony/dotenv v4.4.37 Registers environment variables from a .env file
symfony/flex v1.19.5 Composer plugin for Symfony
symfony/framework-bundle v4.4.49 Provides a tight integration between Symfony components and the Symfony full-stack framework
symfony/proxy-manager-bridge v4.4.39 Provides integration for ProxyManager with various Symfony components
symfony/twig-bundle v4.4.41 Provides a tight integration of Twig into the Symfony full-stack framework
symfony/yaml v4.4.45 Loads and dumps YAML files
twig/extra-bundle v3.6.0 A Symfony bundle for extra Twig extensions
twig/intl-extra v3.6.0 A Twig extension for Intl
twig/twig v3.6.0 Twig, the flexible, fast, and secure template language for PHP
Unfortunately I cannot help you with size limit. Standard application based on Symfony are so big. Best way is to shrink this app somehow, it depends on your use-case. Also run standard symfony application with all GUI and other thing is not good for lambdas from my point of view. I use PHP lambdas for API endpoints or some micro applications.
I have the same issue, but my project is Laravel and its giving 53 Mbs, so its possible just messing with the dependencies lower it to 50 mega?
You can test this package, https://github.com/dg/composer-cleaner, to clean unused stuff from vendor.