Gift of Growth Sale-mobile

HomeBlogDevOpsWhat is Blue Green Deployment?

What is Blue Green Deployment?

Published
06th Feb, 2024
Views
view count loader
Read it in
8 Mins
In this article
    What is Blue Green Deployment?

    Deployment is the process of updating code and other activities on the server to make software available for use.

    In the current situation, there is an increase in demand for continuous deployment to stay current with software updates, so as to provide the user with good quality application experience. There are many techniques available in the market for this, and in this article, we will be discussing about Blue Green Deployment.

    What is Blue-Green Deployment?

    Blue Green Deployment is a software release model that consists of two identical production environments; Blue and Green, configured in a way where one environment is live and the other is in staging (idle) state.

    The idea behind this is to redirect traffic between two environments running with a different version of the application.

    This process eliminates downtime and reduces the risk that happens due to deployment.  In case any error occurs with the new version, we can immediately roll back to the stable version by swapping the environment.

    In some organizations, it is also termed as Red Black Deployment.

    Working of Blue Green Deployment:

    To implement Blue-Green deployment, there should be two identical environments. Also, this requires Router or Load Balancer so that traffic can be routed to the desired environment.

    In the image, we have two production environments, Blue and Green. The Blue environment is one where current (let's say version 1) of the application is running and is live as well. All the traffic of the application is directed to Blue by Router or load balancer (as per the infra set up). Meanwhile, version 2 of the application is deployed and tested on Green Environment.

    Working of Blue Green Deployment

    Currently, at this stage, we can refer to Blue environment as Live and Green as idle or at staging state.

    Once the code for version 2 is tested and ready to be live for production, we redirect the traffic from Blue Environment to Green Environment, making Green as Live and Blue as a staging environment. If any problem is detected with the Infrastructure or application after version 2 is made live, we can roll back to the previous version just by swapping the environment.

    Working of Blue Green Deployment

    Blue Green deployment matches all requirements of seamless, safe and fully reversible conditions for ideal deployment, but there are some practices that need to be adopted for smooth process, for eg. automating the workflow so that there is minimum human intervention, reducing chances of manual error.

    Along with that, it is also important to keep monitoring in place for Blue Green application.

    Tools and Services for Set-Up:

    Based upon infrastructure and application, there are various services i.e. Docker, Kubernetes,  Cloud, Cloudfoundry etc available which can be used to implement Blue-Green Deployment.

    We will be discussing further on Blue Green deployment on Cloud and the steps to implement it.

    The advent of Cloud in Blue-Green Deployment:

    The advent of cloud computing in deployment has helped the system to reduce associated risks.

    Cloud utilities of infra management, billing and automation have made it easier to implement Blue-Green Deployment, making it a quicker task at a lower cost.

    AWS Services for Blue-Green Deployment:

    By utilizing AWS for Blue-Green Deployment, we can access many services that help in automation of deployment and infrastructure i.e. AWS CLI, SDK, ELB, Elastic Beanstalk, CloudFormation etc. There are a number of solutions that AWS provides which we can use, some of them being:

    • DNS Routing with Route53
    • Swapping of Autoscaling Group with ELB
    • Using Elastic Beanstalk and swapping Application
    • Blue-Green Deployment using AWS Code Deploy
    • Cloning Stack in OpsWork and Updating DNS.

    We will discuss Using Elastic Beanstalk and swapping Application in detail:

    Using Elastic Beanstalk and swapping Application

    Elastic Beanstalk provides us with the ease in deployment. Once we upload application code with some version  on Elastic Beanstalk and provide information about application, it deploys our application in Blue Environment and provide its  URL. 

    The above Environment configuration is then copied and used to launch the new version of application-i.e. Green Environment with its  different and own URL.

    This point of time our application is Up with two environments but traffic is going only to Blue Environment. 

    Using Elastic Beanstalk and swapping Application

    For Switching the environment to Green and serving traffic to it, we need to choose other  Environment details from Elastic Beanstalk Console and Swap it using Action menu. It leads Elastic Beanstalk to perform DNS Switch and once DNS changes are done, we can terminate Blue Environment. In this way, traffic will be redirected to Green Environment.

    Using Elastic Beanstalk and swapping Application

    For Rollback, we need to invoke the Switch Environment URL again.

    Steps to perform Blue-Green deployment in AWS:

    • Open Elastic Beanstalk console from AWS and select the Region where we need to set up an environment. 
    • Either we can launch a new environment or clone the existing environment. 
    • Deploy and test the new application environment. For deploying, the new version chooses Environment and name from the list. Click on upload and deploy. 
    • We can use screen form to upload source bundle. 
    • On the Overview page, choose Environment action and choose Swap environment URL.
    • Choose the environment name, under Select an environment to swap column and click on Swap.

    Steps to perform Blue-Green deployment in AWS

    Who Can Benefit from Blue-Green Deployments?

    Blue-Green Deployment provides us with minimum Down Time and reliable deployment.

    Blue-Green Deployment has become useful in deploying an application for Development Teams, but it can be used under the below scenarios:

    • There should be identical and isolated environments.
    • There should be the provision for router or Load Balancer.
    • System should work with Continuous Update.

    Different Types of Deployment

    There are a number of deployment techniques being used in the industry to deploy the application. As a DevOps Engineer, it becomes important to know the insights about different techniques based on our infrastructure providing and choose the right technique as per the impact on the end-user. 

    1. Blue-Green Deployment: Blue Green deployment provides us with high availability and rollback in case of critical bugs found. It consists of two environments running in parallel. One environment will be live and others will be in staging, thereby, making our application downtime free. 
    2. A/B Deployment: A/B Deployment is similar to Blue-Green Deployment with the difference that we send a small amount of traffic to another Server (another environment). The usage of A/B Deployment is generally when we need to check the utilization of features in the application.
      Along with that, it can also be used to check user feedback on the new version. 
    3. Canary Deployment: Canary deployment is used when we need to release the full features of the application in subsets. Generally in Canary, we have a set of servers assigned to a different set of users. This deployment is important when we need to deploy features along with getting feedback 
    4. Rolling Deployment: In Rolling Deployment, there is a process where we replace currently running code server with a new version in a tandem way. Pausing the deployment is much easier in this.

    Advantages of Blue-Green Deployment

    1. No Downtime Deployment:  With Blue Green Deployment, whenever there is a critical bug found on the production server, traffic is redirected to other environments. This leads to no downtime for the end-user. 
    2. Standby: Whenever there is a system failure, we can immediately perform rollback and recover safely without disturbing the end-user.  With Blue Green deployment, once we switch to the new version of application, the older version of the application is still available. Therefore, in case of recovery, we can easily swap the environment and redirect the traffic back to the old version. Blue Green has proven to be impactful in reducing risk in the application development process. 
    3. Immediate Rollback: In some cases where the new feature is not working properly, we can switch to the older feature of application by performing a rollback. 
    4. Testing in Prod Environment: There are scenarios when deploying a new set of code works fine on local, but when deployed in the larger infrastructure, it becomes problematic. By using Blue-Green Deployment, we can check the performance of code on the Prod server without disturbing users.

    Disadvantages of Blue-Green Deployment:

    Since many people are heading toward Blue-Green Deployment, there are some cases where this process is not recommended.

    In some cases, it involves risk which makes deployment more prone to failure and breakdown.

    1. Database Sync Up: Schema changes are complex to decouple. In the case of Blue Green deployment, syncing of database and data changes should be synchronized between the Blue and Green environment. In case of relational database, it can lead to discrepancies.
    2. QA/UAT Identify of Failure: In some scenarios, with large infra, it is possible that sometimes QA test cases will not detect errors/bugs in a non-live environment
    3. Dashboard Required: Since we have two identical production environments with a different version of code, while running the deployment it becomes important to monitor insights with packages and code at any point of time to trigger things.
    4. Cost: For Blue-Green Deployment, we have two sets of environments running in parallel all time, thus increasing the cost of two production environments and maintaining them.

    Conclusion:

    Blue Green deployment is one of favourable technique to deploy application . Since every deployment technique and application has its own pros and cons , therefore team should collaborate and work on choosing the right deployment technique for their application according to tools, and services used to host your application. 

    For deployment technique to work on, there is no fixed approach that will suit and work in every scenario. there should be extensive research before settling for any deployment technique.

    Profile

    Kanav Preet

    Author

    Kanav is working as SRE in leading fintech firm having experience in CICD Pipeline, Cloud, Automation, Build Release  and Deployment. She is passionate about leveraging technology to build innovative and effective software solutions. Her insight, passion and energy results in her engaging a strong clientele who move ahead with her ideas. She has done various certifications in  Continuous delivery & DevOps (University of Virginia), tableau , Linux (Linux foundation) and many more.

    Share This Article
    Ready to Master the Skills that Drive Your Career?

    Avail your free 1:1 mentorship session.

    Select
    Your Message (Optional)

    Upcoming DevOps Batches & Dates

    NameDateFeeKnow more
    Course advisor icon
    Course Advisor
    Whatsapp/Chat icon