Ever heard of “application outage”? As part of agile practice we release our work frequently and often when a newer version of an application released to production, we get application outages due to issues like unexpected traffic, introduced a bug into the newer version or other unknown PITA issues. This cause some (actually a lot!) of chaos in terms of time efforts to recover from failures and having a hassle-free release. In this blog, we will talk about “blue-green” deployment which overcomes such problems in a great way and minimizes the downtime of the applications.
What is Blue Green deployment?
The origin of the term blue-green deployment is unknown to me but I came across this while reading Martin Fowler’s blog. The blue-green deployment is a pattern used to reduce downtime by using two identical production environment such that one of them is live at a time with stable production version and other is idle as a temp to deploy the wannabe stable version.
How it works?
Following the above image suppose there are two identical production environments blue and green. Prior to release “Green” is in action with stable version “1.0.0” deployed to production and you are planning to release the next version 1.0.1. Now as part of release preparation, you can use “Blue” as staging and do all the testing required and once the next version 1.0.1 is stable and meeting all expectations, you switch from “Green” to “Blue” (post-release) which is having the latest version as an officially released version of the application. In case something bad happens with the released version, again the switch is toggled and “Green” is live again with the previous stable version.
How the switch “Green Blue” happens?
The downtime of your application depends on how faster you switch from Blue to Green and vice-versa. For examples depending upon the architecture of the applications, the switch can happen at various layers. For example, you can switch between two hosts by mapping your different IPs to the same domain or you can reroute your application traffic to the newer instance. I will recommend this article which nicely comments on the various techniques and their trade-off which affect the application downtime. The goal is to have a backup to switch to the safer side.
To explore more about the topic and the implementation details I will recommend the “further reading” section of the original article by Martin Fowler and the below links:
- Implementing Blue Green Deployment on AWS
In the next part of the blog, I will approach a super easy implementation of the pattern with Ansible and Jenkins. Waiting for your comments and inputs. Thanks for reading!