As we know Magento cloud is a flexible ecommerce platform in a cloud hosting environment. It Provides a git-based workflow with automatic build and deployment. But it has an issue with automatic build and deployment.

Takes time to complete automatic deploy 

Development time gets increased

 Downtime gets increased

How does Deployment work in Magento Cloud?

  • By default, it generates static content during the deployment phase when the site is in maintenance mode
  • The site will be Offline until the deployment is complete
  • Deploy time depends on
    • Size of the site
    • Number of changes applied and
    • Static content deployment configuration
  • During the deployment process, all connections queue for up to 5 minutes
  • After deployment  the queue released

What happens when a failure occurs during the build phase?

The site will be in Maintenance mode?

or

Site shows an error in frontend?

Answer: Works fine – No downtime because it never begins the deploy phase.

Follow the below simple steps to implement zero downtime with Magento cloud deployment.

Step 1: Upgrade Ece-Tools

Update the metapackage to the latest version with the following command,

composer require “magento/magento-cloud-metapackage”:”>=2.4.3 <2.4.5″ –no-update

composer update magento/magento-cloud-metapackage

Remove deprecated packages with the below commands,

composer remove magento/magento-cloud-configuration

composer remove magento/ece-patches

Update the ece-tools package with the following command,

composer update magento/ece-tools

Add and commit the code changes of the following files,

composer.json

composer.lock

Step 2: Create A System-Specific Configuration:

Connect to SSH( ssh <project-id-integration>@ssh.us.magentosite.cloud

) and run the following command.

php vendor/bin/m2-ece-scd-dump

Download the generated/updated config.php file from the server, add it in local setup and commit this file to the cloud.

Step 3: SCD (Static Content Deployment)

3 types of SCD with Magento cloud:  build phase, the deploy phase, or on-demand

stage:                                                                                                     

  global:                                                                                                  

    SKIP_HTML_MINIFICATION: true

  build:

    SKIP_SCD: false

Step 4: Reduce Theme Files: 

        SCD_MATRIX:

      “Magento/backend”:

        language:

          – en_US

      “Smartwave/porto”: []

      “Smartwave/porto_rtl”: []

      “Smartwave/mossy_graphics”:

        language:

          – en_US

          – fr_FR

      “vendor/theme_name”:

        language:

          – en_US

Step 5: Speed Up Static Content Deployment: 

        deploy:

            SCD_THREADS: 2

       Note: Max-value – 4

Here is the final script of .magento.env.yaml file.

stage:                                                                                                     

  global:                                                                                                  

    SKIP_HTML_MINIFICATION: true

  build:

    SKIP_SCD: false    

  post-deploy:

    WARM_UP_PAGES:

      – “index.php”

  deploy:

    SCD_THREADS: 2

    SCD_MATRIX:

      “Magento/backend”:

        language:

          – en_US

      “Smartwave/porto”: []

      “Smartwave/porto_rtl”: []

      “Smartwave/mossy_graphics”:

        language:

          – en_US

      “vendor/theme_name”:

        language:

          – en_US

Prema M

Prema M is an Adobe-certified Expert who is a Technical Lead at DCKAP. Her years of experience in Magento solve complex problems, proving the best solutions to our clients. Excellent knowledge of understanding the requirements and software life cycle. She has done many custom integrations and has sound knowledge of API and third-party implementations in Magento. In her free time, she enjoys cooking and listening to music.

Get in Touch

Get Expert Advice

At Klizer, we bring over 18 years of specialized expertise in ecommerce website development and design.

© Copyright 2024 Klizer. All Rights Reserved