23
AWS: Deployment methods
There are a number of strategies or methods of deploying new versions of code to AWS in a Continuous Delivery process. In this post, I will go over some of the common ones such as all at once, rolling deploy, immutable and Blue/Green deploys.
This is the fastest method of deploying new code out to your servers. It is also the most dangerous. When you perform an all at once deployment, a new version of the application is pushed out to your instances at the same time. These instances are taken out of service while the deployment takes place and become available once the process is complete. This method replaces all the code in one deployment action and your users experience downtime while it is happening. If an error occurs during deployment, you have to manually reverse the deployment.
This deployment strategy improves on all at once in that it doesn’t have any downtime. Code is pushed out to instances in batches as opposed to updating all instances at the same time. During the deployment, new and old code will run at the same time until all instances have been updated. Here’s an example, suppose you have code running in six instances and you want to push out a new version of the code using the rolling deployment strategy. You could choose to update the instances in pairs, so you could take 2 instances out of rotation, update them, put them back into service and repeat the process for the remaining instances.
If the deployment fails, only the affected servers will be affected.
A variation of the rolling deployment strategy is the rolling with additional batch method. Here, a new batch of instances is added to the existing set of instances. The new software version is pushed to the new batch and tested. Once it checks out okay, groups of instances are taken out of rotation, updated and put back into service. once the deployment is done, the new batch of instances are terminated. This ensures full capacity during the deployment period.
This is one of the safest deployment methods to use when deploying crucial applications. This method creates a new auto scaling group with EC2 instances and deploys the new version of your application to the new EC2 instances. Once the deployment is done and everything works correctly, the Elastic Load Balancer(ELB) points to the new auto scaling group and deletes the old auto scaling group which effectively terminates the old EC2 instances without any downtime or capacity problems.
If something goes wrong during the deployment, rolling back to the previous auto scaling group that works is simple.
The blue/green deployment strategy is a type of immutable deployment which also requires creation of another environment. Once the new environment is up and passed all tests, traffic is shifted to this new deployment. Crucially the old environment, that is, the “blue” environment, is kept idle in case a rollback is needed. This deployment method requires a DNS change.
In this post, I covered five different deployment methods you can use to deploy new versions of your code in AWS. The methods are all at once, rolling, rolling with additional batch, immutable and blue/green deployments. Each method has its pros and cons. The method you choose to use will depend on your needs, budget and clients. Thanks for reading. If you enjoyed this, please consider following me on Twitter.