Problem
In-place upgrades expose users to partially deployed code and make rollback slow and stressful. Releases that require maintenance windows reduce availability and push teams toward infrequent, risky deployments.
Release new versions by running two identical production environments and switching traffic between them instantly.
In-place upgrades expose users to partially deployed code and make rollback slow and stressful. Releases that require maintenance windows reduce availability and push teams toward infrequent, risky deployments.
Blue-green deployment keeps two identical production environments. One is live, the other idle or staging the next release. The release becomes a routing decision instead of a risky in-place mutation, which turns rollback into a fast and well-rehearsed action.
Blue serves all customer traffic while green is provisioned from the same infrastructure definition and receives the new build. Automated smoke tests, synthetic transactions, and health checks run against green using internal routing. When the checks pass, the load balancer target group or DNS weight changes so that green becomes live. Blue is retained, untouched, as the rollback target until a soak period completes, after which it becomes the staging area for the next release.
# Kubernetes service selector flip
apiVersion: v1
kind: Service
metadata:
name: checkout
spec:
selector:
app: checkout
track: green # change from blue to cut over
ports:
- port: 80
targetPort: 8080
Teams adopt this approach when releases need near-instant rollback; the application is stateless or its state is shared and backward compatible. It is a poor fit when database schema changes are destructive and cannot be made backward compatible, or when infrastructure cost of a duplicate environment is prohibitive. The central tensions are rollback speed vs infrastructure cost; release simplicity vs blast radius; environment parity vs operational overhead. The main benefits are that it delivers: rollback is a routing change rather than a redeploy; full pre-release verification in the real production topology; no mixed-version traffic during normal operation; simple mental model for operators and auditors. The main costs to budget for are: doubles infrastructure during the release window; shared databases require careful expand-and-contract migrations; all users switch at once, so blast radius is total; in-flight requests and sessions need explicit draining. Governance typically looks like this: release owner approves the traffic switch after automated verification gates. Expect adoption cost to be medium: duplicate environments and routing automation, and a best fit for small to large teams with automated infrastructure. Critics point out that shared databases undermine the isolation the pattern promises, and that the big-bang switch gives no gradual exposure to detect subtle regressions. Treat these concerns as design inputs, and revisit the decision as traffic, team size, and failure history change.