AWS - Immutable Deployment

 

The AWS service most commonly associated with immutable deployments is AWS Elastic Beanstalk.

Immutable deployment is often confused with blue/green deployment strategy.

The word immutable means something that is unchanging over time or unable to be changed. It’s often used to describe things that are fixed, permanent, or resistant to modification.

Let's say your application is deployed as below:


So, we have a load balancer with a target group attached to a auto scaling group and there are 3 instances serving traffic for an application version1.

Now, you want to deploy application of version2 without any downtime using Immutable deployment strategy. 

This starts by creating a another ASG with one instance deployed with application version2.


At this moment, there are totally 4 instances.

And the load balancer routes traffic to all the 4 instances in round robin fashion. Once the new instances look good, ASG count on v2 version increased by 2 and the ASG count on v1 is set to 0.



This is method is called "Immutable Deployment" where no downtime required. In case of any issues rollback is straight forward, Scale up ASG 1 and scale down ASG 2.

In this strategy, at some point your application will serve traffic for version 1 and 2.

What is BLUE/GREEN?

There are many services like AWS Elastic Beanstalk, ECS, EKS, Lambda, API GW and CloudFormation uses this strategy. 

This primary focus on swapping the traffic by making changes in the Load balancer layer.

Let's go with the same example as above.



We create another ASG2 and add it to the target group and remove ASG1 from the target group.

If there are any issues, we add ASG1 back to the target group. This strategy allows only one version of the application to take traffic and roll back is much faster compared to immutable strategy. But, the cost is bit high as we have to run two versions of the application with full capacity.



Comments

Popular posts from this blog

K8s - ETCD

SRE/DevOps Syllabus

K8s - Deployment and HPA replicas