
You don't have to imagine how frustrating 503 maintenance pages and other error messages are. Everyone hates them — merchants lose potential customers while the latter get interrupted when shopping. It's a lose-lose situation.
Every developer knows that errors on the page are a part of the Magento deployment, including the Magento static content deployment process. But very few actually know how to avoid it with the zero downtime deployment.
So today we'll break down every detail of how the zero downtime deployment works and why you need it. You'll also learn whether can you actually achieve zero downtime without buying Magento Commerce.
But let's start with the basics first.
How Does Magento Deployment Work?
Deployment is a method of building modules, patches and other code and delivering it to end users through different environments. In other words, it's pushing new code from one environment to the other.
These environment usually include:
- Local — where developers build the code.
- Testing — where developers review the code, run tests and fix any errors.
- Staging — where developers make final quality checks and show the developed code to the recipient. Staging mirrors the live site completely.
- Production — where developers make their code available for the end-users.
So, how does moving code from one environment to the other actually work in Magento? It's not just copying the code. The process comes down to running three commands after the code is uploaded:
- bin/magento setup:upgrade — flushes the cache, deletes dependency injection (DI) PHP classes and static content
- bin/magento setup:di:compile — generates dependency injection PHP classes in the "generated" folder
- bin/magento setup:static-content:deploy — generates .phtml files in the "var/view_preprocessed" folder, and JS, CSS, JSON, images, and other static files in the "pub/static" folder
If your Magento is in the production mode, your website is down the entire time — from the first to the last command — which creates some drawbacks.
Drawbacks on Default Magento Deployment
Although the end results are meant to improve user experience, deploying the changes usually causes a lot of inconveniences for both users and merchants. We'll discuss only the most common ones.
Interrupted shopping experience
To run deployment commands developers need to interrupt the website. This stops all storefront processes since your website becomes unavailable for browsing.
Depending on the changes being deployed, deployment may take from a few minutes to much longer.
Not everyone is willing to stay around waiting for the website to become available again. This leads to merchants losing potential customers and sales during deployment.
Inconvenient deployment time
The second drawback is more related to the developers's side. To avoid the former inconvenience, merchants request deployment be run when there are little to no customers on a website. So, it doesn't interrupt the shopping process.
Unfortunately, most websites have little to no customers only at the late evening or nighttimes. Not very convenient for the person running the deployment right?
Unexpected errors
Although developers might have checked the changes multiple times on the testing and stage environments, some issues might still arise during deployment.
If it fails for some reason, your website is stuck in the middle. This only increases the downtime raising merchants' stress levels through the roof.
While this is not that likely to happen, there's still a chance.
What is Zero Downtime Deployment?
Now that you see all the cons of the default Magento deployment process, you might wonder if there is a way to avoid all this fuss. There is — zero downtime deployment.
Your website is never down during the zero downtime deployment. All because the web server doesn't serve the changed code until deployment is complete.
This way you can:
- run deployment in Magento whenever you want
- don't interrupt customer shopping journey EVER
- forget about 503 maintenance pages
So how do you get all these?
How to Achieve Zero Downtime Deployment in Magento?
One way to achieve zero downtime deployment in Magento is to use Magento Commerce on Cloud. It uses the ece tools to optimize deployment and achieve zero downtime.
However, considering Magento pricing, that's not the investment everyone is willing to make.
The easier way is to install the
which works perfectly fine on Open Source and Enterprise editions. It not only reduces the downtime to zero but requires less steps to run the deployment.So, basically, it does all the job for you. You just need to run one command.
How Does Zero Downtime Deployment Work?
Now it's time you see how zero downtime deployment works in Magento, compared to the default Magento deployment. First, you start the deployment with only one command — bin/magento magefan:zero-downtime:deploy. The extension does the rest:
- Creates a temporary folder with a copy of your live Magento and runs all processes there. e.g. var/mfzerodwt/instance
- Checks if there are any new extensions to enable and enables them in the temporary folder.
- Runs the bin/magento setup:di:compile command in the temporary folder.
- Runs the bin/magento setup:static-content:deploy command in the temporary folder (only for enabled themes and locales).
- Runs the bin/magento setup:upgrade command with the --keep generated param in the temporary folder to not delete previously generated DI and static content.
- Copies all files from the temporary folder into the live folder in a fraction of a second which is not noticeable.
- Removes the temporary files and folder.
Since the deployment runs in the background in a separate folder you don't get any downtime on the frontend. But the best part is you can achieve zero downtime deployment in Magento with and without Git.
Give Zero Downtime Deployment a Try
Your store constantly changes — you add new extensions, update design, optimize checkout and other pages. But you need deployment to push all these changes to your live website.
So, while you can't avoid it altogether, you can at least ensure it causes no interruptions on the frontend. Magefan will help with that since we offer you zero downtime deployment commands for every case. Just give it a try.