We are proud to release our newest solution MGT Code Deploy, a zero downtime deployment solution for Magento on AWS. The last few years taught us what our customers really need in order to rapidly release new features.
We developed MGT Code Deploy to meet the following criteria:
Easy to Use
At MGT-Commerce, we develop solutions we love to work with. During our development process, we gather feedback from many partners and customers to find out if they like our ideas and how to improve our solutions even more. Developing new features for Magento demand a lot of time and we wanted to make it as easy as possible to bring them into a test environment and to production. Our MGT Code Deploy solution is designed to deploy new versions with a single click – fully automated.
One requirement for our deployment solution was to have no downtime during updating servers with the latest code version. You may have customers in the checkout who are about to finish their order, and don’t want to lose them because of downtime caused by updating the new version. We achieve zero downtime by switching a release via a symlink.
In a dynamic AutoScaling environment, you never know exactly how many web servers you have because it depends on your traffic. When you run big marketing campaigns, you may have 10 web servers in service or less. We use the API from AWS to get all active instances in order to ship them to the most recent code version.
Performance is the key, especially when it comes to code deployments. With the release a new version or a hotfix for a bug, you need a very fast solution to update your servers. Updating the code in a single server environment isn’t really a problem, but when you have 4, 10 or 20 web servers, e.g. in an AutoScaling environment, you can’t update each server one by one. To ship the deployment package to each server at the same time, we use a message queue (RabbitMQ).
Most of our customers have different environments to deploy on. The production environment is usually a multi server environment with at least two web servers to achieve high availability. Test, staging and dev environments are mostly single server environments. With our MGT Code Deploy solution, we can configure different environments. In the top right corner, you can select the environment you want to deploy in.
For multi environments, you need a user management because not all users should have permission to deploy to all environments. Our user management enables you to create users, which can be restricted to specific environments, for example junior developers can deploy only to staging or test environments before the lead developer merges the version to deploy it to production.
Most of our customers use private github, bitbucket or gitlab repositories for their projects, but some bigger companies use their own hosted git solution because of company policies. MGT Code Deploy works with all git repositories, there are no limitations.
MGT Code Deploy – Step by Step
First of all, you need to log in to MGT Code Deploy’s interface. Select an environment to deploy by using the option in the top right corner.
In the section “Deployments”, choose a new deployment and enter your git username and password. After that, select a branch or tag to deploy. Select “After Deployment Commands” to be executed after the deployment is complete.
Building Deployment Package
The deployment package will be be built by MGT Code Deploy by firstly cloning the git repository, secondly validating the git repository, and finally executing defined “After Clone Commands”, e.g. setup:di:compile and setup:static-content:deploy for Magento.
Deployment Package Delivery
Once the deployment package is finished, MGT Code Deploy automatically ships it to each instance and waits for all instances to be ready.
By switching a symlink, all instances get the latest version. After switching the symlink, “After Switch Commands” (e.g. reloading PHP-FPM) are taken care of.
If previously selected, “After Deployment Commands” (e.g. clearing Magento Cache or Purging Varnish Cache) are executed at the end of the process.
Didn’t You Just Reinvent the Wheel?
Before we start the development of a solution that may take many months, we do research to avoid wasting a huge development effort. There are many, many great solutions on the market, but unfortunately they aren’t AWS AutoScaling compatible and don’t fulfil the specific requirements we had for Magento deployment. We aren’t fans of recreating something that’s already out there, but sometimes, we have to in order to make our customers as happy as possible. So yes, the wheel has already been invented, but this wheel model was uniquely designed and optimised to cater perfectly to Magento on AWS.
What’s the Technology behind MGT Code Deploy?
MGT Code Deploy has been developed with the php framework symfony. It’s running on PHP 7.0, NGINX and has it’s own MySQL database. For the message queue, we use RabbitMQ. We ship MGT Code Deploy as a preconfigured isolated docker container. It can run on a separate instance or on the same instance, for example if you only have a single server environment.