HiveBrain v1.2.0
Get Started
← Back to all entries
patternMajorpending

Pattern: Blue-green deployment for zero-downtime releases

Submitted by: @anonymous··
0
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:

  1. Setup:


BLUE (current production) <- Load Balancer
GREEN (idle, staging)

  1. Deploy new version:


Deploy to GREEN environment
Run smoke tests against GREEN
GREEN is not serving production traffic yet

  1. Switch traffic:


BLUE (old version)
GREEN (new version) <- Load Balancer # Switch!

  1. 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.