Blue-green deployment separates preparing a release from exposing it to production traffic. The blue environment serves the current version while the green environment receives the replacement version. Engineers provision green, deploy the application and its configuration, validate readiness, and then redirect production traffic. The colors are labels rather than permanent roles: after a successful release, green becomes the active environment, and the previous environment can be retained temporarily or removed.
In the cloud, the environments might be separate groups of virtual machines, container task sets, or published serverless function versions. A load balancer, gateway, or function alias provides the traffic-switching mechanism. Infrastructure as code and versioned deployment artifacts help make the environments reproducible. This supports immutable infrastructure because engineers replace application instances rather than patching the running production fleet. However, blue-green deployment is a release strategy, while immutability is an infrastructure-management principle; neither automatically guarantees the other.
A practical web application release might create a replacement instance group from a new machine image, register it with a separate load-balancer target group, and run tests through a nonproduction listener. After checking authentication, dependency access, latency, and application behavior, the pipeline changes production routing. It drains existing connections where supported and retains the old group during an observation period. Long-lived connections, sticky sessions, caches, and DNS caching can delay complete transition, so a traffic switch is not necessarily instantaneous and does not guarantee zero downtime.
Database compatibility is often the most important rollback constraint. Both versions commonly share a production database, although separate databases are possible with a carefully designed synchronization strategy. Use backward-compatible schema changes, such as adding a nullable column before removing an old one in a later release. Returning traffic to blue does not undo writes, reverse external transactions, or restore deleted data. Session state should remain accessible to both versions, and background workers or scheduled jobs need coordination to avoid duplicate processing and incompatible writes.
CI/CD pipelines should automate environment creation, deployment, readiness checks, test execution, traffic switching, observation, and cleanup. Define rollback conditions using metrics such as error rate, latency, failed business transactions, or inference failures. A passing infrastructure health check is not proof of application correctness. Keep the old environment healthy and sufficiently provisioned during the rollback window, and confirm that rollback is actually possible after any data or configuration changes.
For AI and machine learning workloads, green can host a new model, inference container, or replacement AI platform integration. Validate input schemas, preprocessing, feature availability, representative datasets, output quality, inference latency, and cost per request before switching. Business continuity may require a fallback model or a manual process if the new system fails. Technical health alone cannot establish model quality; some business outcomes arrive too late for immediate automated rollback. Account for sensitive production data used in validation and for the temporary cost of duplicate inference capacity.
The main trade-offs are additional capacity, orchestration complexity, environmental parity, and state-management effort. Quotas must support overlapping environments, and green must handle expected production demand before cutover. Blue-green describes the coexistence of current and replacement environments; canary describes exposing a limited portion of traffic before broader rollout. They can be combined, although a classic blue-green cutover moves traffic in one step. Neither strategy replaces backups, multi-zone resilience, disaster recovery, or a tested operational recovery plan.