Blue Green Deployment

AWS: Blue Green Deployment

Exam Objective

The topic “Blue Green Deployment using Auto Scaling Launch Configurations” addresses the Continuous Delivery and Process Automation topic as highlighted in the AWS Blueprint for the exam guide

AWS Certified DevOps Professional

One of the key requirements of this topic is the concept of Continuous Deployment. The Blue Green Deployment concept is an important concept. This now a widely held practice in many organizations that look towards continuous delivery.

What is Blue Green Deployment?

The below diagram from AWS demonstrates the Blue Green deployment scenario.

Blue Green Deployment

Here the Blue environment is the production environment which is currently serving traffic to the end users. The Green environment is a parallel and duplicate environment which has the new release of the application. When the new application version needs to be released, the switch is made from the Blue environment to the Green environment. The users will then be directed to the new environment and get the new application version. The advantages of such a deployment are

  1. Ease of deployment – Here the deployment of the new version is just a simple switch which can happen at the DNS level. This reduces the amount of downtime which would be rendered to the users when the application moves to the new version.
  2. Risk reduction – Ideally before deployment the Green environment, a thorough check would be made to ensure that the environment was functionally working as per the requirements. This would make the release less prone to risk when the actual cutover is completed.
  3. Easy to rollback – After the switch is made from the Blue environment to the Green environment, the Blue environment can be kept running until it is ensured that the Green environment is working as it should. This is so that if there are any issues with the newly deployed environment, it becomes easier to shift back to the older environment.

There are many ways to carry out Blue Green Deployment. This topic focuses on how it can be accomplished by modifying the launch configurations of the Autoscaling Group.

Implementing Blue Green Deployment with New Launch Configurations

Now let’s have a closer look at how we can achieve Blue Green deployments with a change in Launch configurations.

Step 1) Log into your AWS Console. Go to the EC2 section.

Auto Scaling Groups

Step 2) Create a new launch configuration. Let’s say a launch configuration is created with the Instance Type of t2.micro.

Creating New Launch Configuration

Step 3) Next, create an Autoscaling Group from the launch configuration. For the purpose of this demo, we can keep the initial number of instances to 2.

Autoscaling Group

So, in the above example, we have an Autoscaling group which has a Desired, Min and Max value of 2. You can also attach the Autoscaling Group to a load balancer if required.

If you were to the Instances section, you would see 2 instances InService.

Blue green deployment

Step 4) Now let’s say you want to deploy the newer version of this application, but using a new Instance Type, let’s say t2.small. Create a new Launch configuration. You can name this launch configuration as “newlaunch”

Note:- Remember that you cannot change a launch configuration once it is created

Launch Configuration

Step 5) Now let’s attach this new launch configuration to the Autoscaling Group.

Note:- Remember that the Autoscaling Group can only be associated with one launch configuration at a time.

Go to the details of the Autoscaling Group and click on the Edit button

Autoscaling Group

Step 6) Change the Launch configuration to the newly created Launch configuration and then click on the Save button

Launch Configuration

Step 7) Now increase the Max and Desired size of the Autoscaling Group to 4 by editing the Autoscaling Group. Then click on Save.

Autoscaling Group Editing

Step 8) Now if you were to go to the Instances tab for your Autoscaling Group, you would see 2 new instances launching that are part of the new launch configuration.

AWS Certification

This means that the ELB which is attached to the Autoscaling Group would now start registering the new instances

If you were to go to the ELB dashboard and check the ELB, you would see all four instances.

Step 9) Now to remove the older instances, you could either mark the older services in the Standby state by using the CLI so that requests are not routed to these instances. Or you can even terminate the instances if required.

Or you can perform the following steps to change the size of the Autoscaling Group.

Azure Certification

Go ahead and change the Max and Desired values of the Autoscaling group back to 2.

You would then start seeing that the Instances of the “Initial” Launch configuration start getting terminated. This is because the default termination policy of the Autoscaling Group during a scale in the process is to remove the instances which have the older launch configuration.

Cloud Computing

If you ever need to rollback, then you can do the vice versa of the above step1

1) Since you still have the older launch configuration, you can attach the Autoscaling Group to that launch configuration.

2) Change the Desired and Max values to 4 of the Autoscaling Group

3) Once the instances of the older launch configuration have been launched, change the Desired and Max values to 2 of the Autoscaling Group

Final Points to Remember 

1) The Blue environment is the production environment which is currently serving traffic to the end users

2) The Green environment is a parallel and duplicate environment which has the new release of the application

3) The Blue Green deployment has the following advantages

  • Ease of deployment
  • Risk reduction
  • Easy to rollback

4) Remember that you cannot change a launch configuration once it is created

5) Remember that the Autoscaling Group can only be associated with one launch configuration at a time

[divider /]

Whizlabs AWS Certified DevOps Professional Practice Tests help students to get mentally prepared for the actual certification exam. Practicing several times through AWS mock tests before the certification exam, makes you better prepared for the real one.

About Pavan Gumaste

Pavan Rao is a programmer / Developer by Profession and Cloud Computing Professional by choice with in-depth knowledge in AWS, Azure, Google Cloud Platform. He helps the organisation figure out what to build, ensure successful delivery, and incorporate user learning to improve the strategy and product further.

0 thoughts on “AWS: Blue Green Deployment”

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top