DEV Community

Nitin Kalburgi
Nitin Kalburgi

Posted on

Blue/Green Deployment with Load Balancer and Auto-scaling in AWS

What is Blue/Green Deployment?
A blue/green deployment is a deployment strategy in which we create two separate, but identical environments. One environment (blue) is running the application version which is live and currently serving the production environment. One environment (green) is running the new application version with new changes. Using a blue/green deployment strategy increases application availability and reduces deployment risk by simplifying the rollback process if a deployment fails, also ensuring zero downtime for our release. Once testing has been completed on the green environment, live application traffic is directed to the green environment and the blue environment is deprecated.

Terminologies:
Green Nodes - The EC2 Instances which are currently serving the live production environment.
Blue Nodes - The EC2 Instances with the new changes which has to be released in production.
Blue Load Balancer - The load balancer serving the live production environment.
Green Load Balancer - The load balancer which will be used for Green environment.

Infrastructure required:
We need to create a new "Green Load Balancer" and a new target group "Target Group - 2" and attach it to "Green Load Balancer" which forwards the traffic with traffic weight 100%. Also create a new target group "Green Target Group" which we'll be using later.
The current live production environment will have a "Blue Load Balancer" which has a rule that forwards traffic to a target group "Target-Group-1" with traffic weight 100%.
Attach target group "Target-Group-2" to "Blue Load Balancer" with traffic weight 0%. So, the current running environment won't be affected.

Image description

Deployment Steps:
Step-1: Green Deployment

As part of Green Deployment Job we are detaching the target group which is attached to "Green Load Balancer" auto-scaling group .i.e. "Target Group-2 and we'll attach the "Green target group" which we have created earlier. Later we'll deploy the new version of application in this for green testing.

Image description

Step-2: Blue Deployment

As part of Blue Deployment Job we again deploy the new version of application to "Target Group-2" and switch the weight to send all traffic from this. Detach the "Green target group" from green auto scaling group and attach the one which is at 0% in Blue .i.e. "Target Group-1".

Image description

Step-3: Reduce old blue Instances

The last step after the testing in new version would be reduce the old version instances capacity from old "Blue Auto Scaling Group" and bring it to zero.

Image description

The Blue/Green Deployment is completed.

Top comments (1)

Collapse
 
nitinkalburgi profile image
Nitin Kalburgi

I'm open to any improvements on this architecture.