Middle
What is Blue-Green deployment?
sobes.tech AI
Answer from AI
Blue-Green deployment is a release strategy for new features with minimal downtime, based on maintaining two identical environments: "blue" (current, live version) and "green" (new version).
Algorithm:
- There is an active "blue" environment serving all traffic.
- The new application version is deployed in a fully identical but inactive "green" environment.
- After successful testing of the "green" environment, traffic is switched to it.
- The "blue" environment is kept for quick rollback or can be used for subsequent deployments.
Key advantages:
- Minimal downtime: Traffic switching is almost instantaneous.
- Easy rollback: In case of issues with the new version, traffic can be easily redirected back to the "blue" environment.
- Lower risk: The new version is tested in an isolated environment before switching traffic.
Disadvantages:
- Double resources: Resources are required to maintain two full environments.
- State management: Managing application state can be challenging if it uses a database with constant changes.
Example of traffic switching using a load balancer:
// Simplified load balancer configuration
{
"listeners": [
{
"port": 80,
"protocol": "HTTP",
"default_actions": [
{
"type": "forward",
"target_group_arn": "arn:aws:elasticloadbalancing:..." // ARN of the "blue" environment target group
}
]
}
]
}
# Command to switch traffic to the "green" environment
# (example for AWS CLI, assuming the ARN of the new target group is available)
aws elbv2 modify-listener --listener-arn "arn:aws:elasticloadbalancing:..." --default-actions Type=forward,TargetGroupArn="arn:aws:elasticloadbalancing:..." // ARN of the "green" environment target group