0

I'm using Magento 2.3.4 open source and I am looking into how I can achieve zero downtime

The build commands I normally use are:

php bin/magento maintenance:enable
composer install --no-interaction
php bin/magento setup:upgrade
php bin/magento deploy:mode:set production --skip-compilation
php bin/magento config:set dev/css/merge_css_files 1
php bin/magento config:set dev/css/minify_files 1
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy en_GB en_US
php bin/magento indexer:set-mode schedule
php bin/magento indexer:reindex
php bin/magento cache:clean
php bin/magento cache:enable
php bin/magento maintenance:disable

This works but requires around 2 - 3 minutes of downtime.

Reading answers like https://magento.stackexchange.com/a/75461/6414 I think it's the best method eg have different releases of files and just swap the symlinks over then do the setup:upgrade which would reduce the downtime to like 30 seconds.

But is there anything better? As that answer is 5 years old

0

when installing a new version of Magento, this is still the way to go.

When you are deploying your changes or new module versions, you can check out if there are actually any changes to the database schema of any module.

If not, you can skip setup:upgrade as well and archive zero downtime.

When you are just changing your code, but want to change the database schema, you can also deploy code, that can work with both database variants and apply the changes directly to live without using Magento's database upgrading at all, but this of course brings some extra risks and is not a "clean" method.

0

You can store dev/css/merge_css_files 1 and dev/css/minify_files 1 in your app/etc/config.php and remove those steps.

This means you could also just run php bin/magento deploy:mode:set production and avoid the need for php bin/magento setup:di:compile and php bin/magento setup:static-content:deploy en_GB en_US as separate commands.

I'm not sure why you're running a reindex every time, or resetting indexer mode unless you're having issues.

So your list would look more like:

composer install --no-interaction
php bin/magento setup:upgrade
php bin/magento deploy:mode:set production
php bin/magento indexer:set-mode schedule
php bin/magento indexer:reindex
php bin/magento cache:clean
php bin/magento cache:enable
php bin/magento maintenance:disable```

0

I created this Deployer Magento 2 recipe to have zero downtime, particularly I think it's the best option to implement a deploy strategy. But if you wanna run manually you can follow the instructions below.

The downtime is required only during the database update via bin/magento setup:upgrade, you will have to update it when a module is updated.

To check if the database must be changed you can run the command bin/magento setup:db:status, which will show a message like that below in case you have updates.

Magento 2 zero downtime

Zero Downtime

To have the zero downtime you have to compile the static files and DI in a different folder and move these compiled files to the production folder, you can do it via pipelines or compiling directly in your server in a parallel folder.

Before moving the files you can check if the database must be updated, if yes, you can put the store in maintenance mode, run the bin/magento setup:upgrade and move the compiled files. After that, you can clean the cache, reindex, flush Varnish, Redis etc..

The downtime with this strategy will be zero, and when required it will be minimal, less then you have today.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.