Whenever we install a new site we use a profile which admittedly has a lot of configuration to import and modules to enable. We are beginning to run into out of memory issues with PHP when running a fresh install. The step which takes the longest is the install_config_import_batch. When I run an install locally, this step takes about 500 seconds and 350+ MB of memory.

What are some ways we can optimize this? Is there a way to skip this config import step and run it after the installation?

Comments

himani_219’s picture

"You can try a few optimizations to reduce memory usage during install_config_import_batch. First, increasing the memory_limit in php.ini might help handle large configurations. Another option is reducing the batch size in core/lib/Drupal/Core/Batch/BatchStorage.php to process smaller chunks at a time, which lowers peak memory consumption. If skipping the config import during installation is feasible, you could install the site with a minimal profile and then run drush cim after installation to handle the import separately. Additionally, temporarily disabling non-essential modules during installation and enabling garbage collection (gc_enable()) before the batch process starts can help free up memory.

oliviacooke’s picture

Great suggestions, Himani! Increasing the memory_limit and adjusting the batch size can definitely help manage memory consumption. Running the config import separately after installation seems like a solid approach to avoid overloading the system during the initial setup. Disabling non-essential modules and enabling garbage collection is also a smart way to free up memory. I'll give these methods a try and see how it works. Thanks for the helpful tips!

stefan lehmann’s picture

Really? Cooking up some AI text to boost your site in a random open source forum?

katherinewright’s picture

Consider increasing PHP memory limit or running imports after installation.