(Part II of III)- ECS Blue/Green Deployment

This is the second part of a three part series.

Part 1: https://nsrblogs1387.medium.com/part-i-of-iii-aws-ecs-autoscaling-deployment-rollback-demystified-2c6a0d25486d

Part 3: https://nsrblogs1387.medium.com/title-part-iii-of-iii-ecs-rolling-update-deployment-ae844d28aa62

In ECS we mainly get two types of deployment options:
— Blue/Green Deployments
— Rolling update Deployments

Differences between these deployments and which one to choose specially with ECS:

— Blue/Green requires double of the running resources in deployment phase, while in rolling update this behaviour can be adjusted.
— ECS Blue/Green Deployment integrated with AWS CodeDeploy to run the deployment which makes it easier to visualise during the deployment, Rolling Update doesn’t integrate with CodeDeploy.
— In ECS Blue/Green, rollbacks are handled natively while in Rolling update you need to manage the rollback (this is improved a lot with CircuitBreaker, but more on this in part III)
— ECS Blue Green Deployment doesn’t integrate with Capacity Provider, while rolling update does.

Blue/Green deployments:

In the Blue Green Deployments, a replica environment (Green) of existing environment (Blue) is created.

The new deployment tasks are executed on the Green environment without impacting the Blue environment.

Once all the tasks in the Green environment are healthy, the traffic is routed from Blue to Green.

All the traffic can be routed at once or gradually (canary way) based on your preference.

So let’s go through the B/G Deployment steps visually:

Stage 1: Start of deployment:

Start of a Blue/Green Deployment

B/G Deployment uses two LB Target Groups one for Blue and other for Green. These Target Groups can be under same listener or different listeners.
As you can see, there are three tasks already running in Blue TG, so start of a new deployment registers three new tasks in Green TG and initially these go in Initialising state.

Stage 2(in successful deployment scenario):

When Tasks register healthy

As soon as the tasks register healthy, traffic is routed all at once or gradually to Green TG.

Stage 3(in successful deployment scenario):

Tiding up the deployment

When all the traffic is routed to new tasks, old tasks are terminated.

Stage 2(in failed deployment scenario):

When the tasks started doesn’t go as planned

When the new tasks fail, the traffic is not routed to them.

Stage 3(in failed deployment scenario):

Go back!!

ECS automatically detects the failure and rollbacks it, which deregisters the new tasks and stops the deployment from creating further tasks.

I hope this puts a clear picture on how the Blue/Green Deployment works with ECS.

I would just like to emphasise on the point that ECS Blue/Green deployments are very interactive due to its tight integration with AWS CodeDeploy.
You can monitor the deployment progress in a very nice CodeDeploy GUI.

You can even monitor the traffic routing from the GUI.

What takes it to the next level is, you can rollback the deployment anytime with a single click if needed.

So this is all about the ECS Blue/Green deployments.

In the next part (part III), I will explain about the ECS Rolling Update Deployment. https://nsrblogs1387.medium.com/title-part-iii-of-iii-ecs-rolling-update-deployment-ae844d28aa62