Skip to content

magento 2 efficiency

Increase PHP Memory When Running Magento 2 Command

When running CLI commands on a Magento 2 installation the issue of memory can arise. For example, when running a composer command the memory limit will sometimes be reached, generating an error and the command being terminated. The ability to increase the PHP memory limit for that command only is needed. The following command is an example where I need to run upgrade composer, but need to increase the memory limit 2048 MB. php -d memory_limit=2048M /bin/composer upgrade

Efficiency When Using Magento 2 Setup Commnds

Magento 2 requires a set of commands to be run after various changes to its installation, whether it be introducing a new extension or upgrading a current one. The following commands required to be run, and commonly run one after the other, are:

bin/magento setup:upgrade
bin/magento setup:static-content:deploy
bin/magento setup:di:compile

In the past I’ve been able to run these commands with little issue, but recently on one particular client’s multi-website Magento 2 installation, which has large cron jobs and higher traffic, the commands caused extremely high CPU usage. It seemed that running the commands with the other regular Magento 2 processes occurring in the background caused severe slow downs and regular site outages until PHP was restarted. In turn, this caused much frustration from both myself, the hosting company, and most importantly the client, who was losing dollars each time customers were unable to make purchases through their sites.Read More »Efficiency When Using Magento 2 Setup Commnds