

# Amazon ECS blue/green deployments
<a name="deployment-type-blue-green"></a>

A blue/green deployment is a release methodology that reduces downtime and risk by running two identical production environments called blue and green. With Amazon ECS blue/green deployments, you can validate new service revisions before directing production traffic to them. This approach provides a safer way to deploy changes with the ability to quickly roll back if needed.

## Benefits
<a name="blue-green-deployment-benefits"></a>

The following are benefits of using blue/green deployments:
+ Reduces risk through testing with production traffic before switching production. You can validate the new deployment with test traffic before directing production traffic to it.
+ Zero downtime deployments. The production environment remains available throughout the deployment process, ensuring continuous service availability.
+ Easy rollback if issues are detected. If problems arise with the green deployment, you can quickly revert to the blue deployment without extended service disruption.
+ Controlled testing environment. The green environment provides an isolated space to test new features with real traffic patterns before full deployment.
+ Predictable deployment process. The structured approach with defined lifecycle stages makes deployments more consistent and reliable.
+ Automated validation through lifecycle hooks. You can implement automated tests at various stages of the deployment to verify functionality.

## Terminology
<a name="blue-green-deployment-terms"></a>

The following are Amazon ECS blue/green deployment terms:
+ Bake time - The duration when both blue and green service revisions are running simultaneously after the production traffic has shifted.
+ Blue deployment - The current production service revision that you want to replace.
+ Green deployment - The new service revision that you want to deploy.
+ Lifecycle stages - A series of events in the deployment operation, such as "after production traffic shift".
+ Lifecycle hook - A Lambda function or pause point at a specific lifecycle stage. Lambda hooks invoke Lambda functions that you have defined to run custom code. Pause hooks pause the deployment and wait for you to call `ContinueServiceDeployment` to proceed.
+ Listener - A Elastic Load Balancing resource that checks for connection requests using the protocol and port that you configure. The rules that you define for a listener determine how Amazon ECS routes requests to its registered targets.
+ Rule - An Elastic Load Balancing resource associated with a listener. A rule defines how requests are routed and consists of an action, condition, and priority.
+ Target group - An Elastic Load Balancing resource used to route requests to one or more registered targets (for example, EC2 instances). When you create a listener, you specify a target group for its default action. Traffic is forwarded to the target group specified in the listener rule.
+ Traffic shift - The process Amazon ECS uses to shift traffic from the blue deployment to the green deployment. For services with a load balancer or Service Connect, Amazon ECS manages the traffic shift automatically. For headless services, Amazon ECS replaces the blue tasks with green tasks but doesn't manage traffic shifting.

## Considerations
<a name="blue-green-deployment-considerations"></a>

Consider the following when choosing a deployment type:
+ Resource usage: Blue/green deployments temporarily run both the blue and green service revisions simultaneously, which may double your resource usage during deployments.
+ Deployment monitoring: Blue/green deployments provide more detailed deployment status information, allowing you to monitor each stage of the deployment process.
+ Rollback: Blue/green deployments make it easier to roll back to the previous version if issues are detected, as the blue revision is kept running until the bake time expires.
+ Network Load Balancer lifecycle hooks: If you use a Network Load Balancer for blue/green deployments, there is an additional 10 minutes for the TEST\_TRAFFIC\_SHIFT and PRODUCTION\_TRAFFIC\_SHIFT lifecycle stages. This is because Amazon ECS makes sure that it is safe to shift traffic.