How to Achieve Zero Downtime Deployment in Magento

How to Achieve Zero Downtime Deployment in Magento

Extensive website downtime can lead to revenue losses for online stores. The cost of downtime can reach $5,600 per minute. Zero Downtime Deployment can help you avoid downtime. It allows you to deploy website upgrades without losing customer sessions. This article covers how to achieve Zero Downtime Deployment for Magento.

What is Deployment, and How does it Work

What is Deployment, and How does it Work

Deployment is a method where modules, updates, and patches are built and delivered to end-users.

Developers build, test, and deploy new code to the application.

The deployed upgrades respond to customer demands and keep your store running optimally.
You can push code changes from one environment to another. It ensures that new upgrades do not affect the live site.

There are different development environments-

  • Local Development - The developers build and test the code on a local machine.

  • Testing - You analyze and review the new code. Run tests and fix errors to ensure the code works correctly.

  • Staging - The staging phase is set to mirror the live site. It is used to make final quality checks and show the new changes to sponsors.

  • Production - The live or production environment is where the changes are available to end-users.

What is Zero Downtime Deployment

What is Zero Downtime Deployment

Zero Downtime Deployment is a method where your website is never down or slow during the deployment stage.

The downtime period is zero, so your site is available to users.

The website changes include:

  • Installing upgrades for hardware or software
  • Upgrading operating systems
  • Code-based updates
  • Security upgrades
  • Configuration changes
  • Technical fixes
  • Database migration
  • Server migration

The web server doesn’t serve the changed code until the deployment process is complete.

Customers can continue shopping and finish check out while changes are being made.

How to Achieve Zero Downtime Deployment for Magento

How to Achieve Zero Downtime Deployment for Magento

Deploying Magento 1 site changes were much simpler.

You did not have to use setup:upgrade command or setup:static-content: deploy to deploy code.

You can pull in the changes, flush the Magento cache and launch the code.

With Magento 2, there are some significant changes. You can manage code with a composer. It requires more configuration on deploying the code.

The process can significantly slow down the site or make it unavailable. A zero downtime deployment is essential for Magento 2.

We cover the three strategies to achieve zero downtime deployment.

1. Blue-Green Deployment Strategy

Blue-Green Deployment Strategy

Blue-green deployment is where you create two separate yet identical environments.

In one environment, Blue is running the current application. The Green environment is deploying the new version of the application.

Only one of the environments is live at a single time. For example, if the Blue environment is currently alive, Green is idle.

The testing verification is done in isolation. Once the code is tested and ready, the new changes are deployed to the Green environment.

The load balancer routes incoming traffic requests to Green instead of Blue.

The Green is now live, and the Blue environment sits idle. The users can see the new changes on the website.

The blue/green deployment strategy helps reduce downtime. It simplifies the rollback process if a deployment fails.

Pros of Blue-green Deployment

  • Achieves zero downtime as a load balancer is switched.
  • The traffic is routed to the new codebase.
  • Tests are done in the production environment.
  • Easily rollback to the previous environment if there is an issue.

Cons of Blue-green Deployment

  • The current transactions or sessions may be lost when the machine is switched.
  • It can cause N-1 data compatibility issues. Both versions of the app have the same underlying database.
  • If older versions do not support the database changes, it can cause downtime.
  • Can get resource-intensive due to multiple environments.

2. Zero Downtime Deployment for Adobe Commerce

Adobe Commerce runs the site in maintenance mode in the deploy phase. It can take your site offline until the deployment is complete.

The downtime will depend on the size of the site and the number of changes.

You can configure your project to deploy it with a zero downtime effect.

Adobe Commerce offers steps to reduce downtime. You can deploy and update to Production quickly.

1. Upgrade to the ece-tools package and update the ece-tools version.

Adobe Commerce on the cloud should have the latest eco-tools package. The tools help configure an optimal deployment.

The zero downtime deployment will work with ece-tools version 2002.0.13 and later.

2. Configure static content deployment

If the static content deployment fails, your site gets stuck in maintenance mode.

When the same failure occurs in the build phase, it avoids downtime. That’s because the failure does not begin in the deploy phase.

You should generate static content in the build phase with minified HTML. It works as an optimal setting for zero downtime deployments.

3. Configure the post-deploy hook

The hooks section runs shell commands in the build, deploys, and post-deploy phases.

The cache clean occurs by default when the site is down.

Moving clean cache to post-deploy means the cache is live until the deploy phase is complete.

You can use the WARM_UP_PAGES variable to customize the pages to preload the cache.

4. Reduce the theme files

You can reduce the number of unwanted theme files. It helps speed up the deployment process.

Configure the SCD_MATRIX environment variable.

5. Speed up static content deployment

Update the SCD_THREADS environment variable. It increases the number of threads for static content deployment.

It helps to speed up the deployment process.

3. Using MGT Code Deploy

MGT Code Deploy is a zero downtime deployment solution for Magento.

The tool initiates “in place” deployments via a simple interface.

You also get high performance Magento deployment on AWS. MGT Code Deploy is designed to use a message queue for parallel running tasks.

It helps improve speed and optimizes data flow.

The Code Deploy tool allows you to release new features rapidly.

The tool is also compatible with Git repositories. You can use private GitHub, GitLab, BitBucket, or your Git repository.

How Does MGT Code Deploy Work?

How Does MGT Code Deploy Work

The following steps cover how the MGT Code Deploy works -

1. Log in to the MGT Code Deploy interface at the starting point of deployment. Select the environment to deploy on the top right corner.

2. Add a New Deployment-

  • Navigate to the Deployments tab and click on the "New Deployment" button.
  • Enter your GIT username and password.
  • Select a branch or tag to deploy the changes.
  • After Deployment, Commands can be added at the end of the form.
  • The commands are executed after the deployment is completed.

3. MGT Code Deploy software starts building the deployment package.

The building process consists of the following steps:

  • Cloning the git repository
  • Validating the git repository
  • Executing defined "After Clone Commands" such as setup:di:compile and setup:static-content:deploy for Magento 2

4. The deploy tool then ships the deployment package to each instance. It waits until all instances are ready.

5. All the instances get the latest version by switching a symbolic link (symlink).

After switching the symlink, the tool executes the defined After Switch Commands.

6. Lastly, the selected After Deployment Commands are executed. It can execute commands such as Clear Magento Cache or Purge Varnish Cache.

Features of MGT Code Deploy

Features of MGT Code Deploy

1. Zero Downtime Deployment

The deploy software enables you to deploy multiple AWS instances simultaneously.

Update the application without replacing infrastructure components. In-place deployments are done by switching the release with a symlink.

As a result, the MGT Code Deploy has zero downtime during the deploy phase.

2. High Performance

High performance is achieved by running parallel tasks with a message queue.

Message queues provide asynchronous communication.

The endpoints consuming messages interact with the queue. It enables messages to wait safely until the receiving application is ready.

No component in the system is waiting for another. As a result, you get high speed while adding updates.

3. Centralized Control

The MGT Code Deploy interface lets you track the status of the deploy phase.

It lets you add admins and different users to the system. All changes are documents and can be accessed via the interface.

4. User Management

The admin can create and manage multiple users. You can assign unique environments to each user.

The software enables effective collaboration between users and allows for successful deployments.

5. Automated Deployments

You can fully automate your Magento deployments. It can be across your development, test, and production phases.

MGT Code Deploy enables you to scale with your infrastructure quickly. You can deploy to one instance or thousands efficiently.


Zero Downtime Deployment ensures your website is live during deploy phases. You can quickly add new features to your site and allow continuous rolling deployment. You can use the blue-green environment or configuration steps for Magento Commerce. MGT Code Deploy will automate deploying with zero downtime.

It enables continuous integration and continuous deployment (CI/CD) for your store. You can also use a Magento 2 profiler

Gain more insights on Magento development at the MGT Commerce blog.

Nikita S.
Nikita S.
Lead Technical Writer

As a lead technical writer, Nikita S. is experienced in crafting well-researched articles that simplify complex information and promote technical communication. She has expertise in cloud computing and holds a specialization in SEO and digital marketing.

Get the fastest Magento Hosting! Get Started