patternMajorpending
Pattern: Blue-green deployment for zero-downtime releases
Viewed 0 times
blue-greendeploymentzero-downtimerollbackload-balancer
Problem
Traditional deployments cause downtime during the update. Users see errors or loading states while the new version is being deployed.
Solution
Run two identical environments, switch traffic instantly:
BLUE (current production) <- Load Balancer
GREEN (idle, staging)
Deploy to GREEN environment
Run smoke tests against GREEN
GREEN is not serving production traffic yet
BLUE (old version)
GREEN (new version) <- Load Balancer # Switch!
BLUE (old version) <- Load Balancer # Switch back!
GREEN (broken) # Fix and redeploy
Implementation approaches:
# DNS-based (slowest, DNS propagation delay):
Update DNS to point to green servers
# Load balancer (fastest):
aws elbv2 modify-listener --default-actions TargetGroupArn=green-tg
# Kubernetes:
kubectl set image deployment/app container=image:v2
# K8s rolling update is blue-green by default
# Docker Compose:
docker compose up -d --no-deps --build app
# With health checks, old container stays until new is ready
# Nginx:
upstream app {
server green-server:3000; # Switch this line
}
nginx -s reload
Key requirements:
- Setup:
BLUE (current production) <- Load Balancer
GREEN (idle, staging)
- Deploy new version:
Deploy to GREEN environment
Run smoke tests against GREEN
GREEN is not serving production traffic yet
- Switch traffic:
BLUE (old version)
GREEN (new version) <- Load Balancer # Switch!
- If problems:
BLUE (old version) <- Load Balancer # Switch back!
GREEN (broken) # Fix and redeploy
Implementation approaches:
# DNS-based (slowest, DNS propagation delay):
Update DNS to point to green servers
# Load balancer (fastest):
aws elbv2 modify-listener --default-actions TargetGroupArn=green-tg
# Kubernetes:
kubectl set image deployment/app container=image:v2
# K8s rolling update is blue-green by default
# Docker Compose:
docker compose up -d --no-deps --build app
# With health checks, old container stays until new is ready
# Nginx:
upstream app {
server green-server:3000; # Switch this line
}
nginx -s reload
Key requirements:
- Database schema must be compatible with both versions
- Session state must be externalized
- Both environments must be identical
- Automated smoke tests before switch
Why
Blue-green deploys eliminate downtime and provide instant rollback. The switch is just a load balancer config change.
Revisions (0)
No revisions yet.