Blue-Green Deployment
Maintain two identical production environments. Only one (blue) serves traffic at a time. Deploy to the inactive one (green), test it, then switch traffic.
How It Works
- Blue environment serves production traffic
- Deploy new version to Green environment
- Test Green thoroughly
- Switch load balancer/DNS from Blue to Green
- Green is now production; Blue becomes the rollback target
Nginx Implementation
# Switch between backends
upstream backend {
server 127.0.0.1:3001; # Blue (active)
# server 127.0.0.1:3002; # Green (standby)
}
# To switch: comment Blue, uncomment Green, reload nginxCanary Deployment
Route a small percentage of traffic to the new version. If metrics look good, gradually increase.
# Nginx weighted upstream
upstream backend {
server 127.0.0.1:3001 weight=9; # Old version (90%)
server 127.0.0.1:3002 weight=1; # New version (10%)
}Comparison
- Blue-Green: instant switch, easy rollback, requires 2x resources
- Canary: gradual rollout, lower risk, catches issues early with small impact
- Rolling: update instances one at a time, no extra resources needed