CLOUD CONCEPT

Blue-Green Deployments

Blue-green deployments release application changes by preparing a separate production-ready environment and switching traffic from the current environment to the new one.

Cloud Concepts Hub →

What is Blue-Green Deployments

Two environments coexist during a release: blue serves the current version while green runs the replacement version for validation and promotion. Separating deployment from traffic cutover reduces release-related downtime and enables rapid traffic rollback, provided application state and dependencies remain compatible.

Blue-green deployment separates installing a release from making that release serve production traffic. The blue environment runs the current application, while a separate green environment runs the proposed replacement. Engineers validate green, prepare it for production load, and then change routing so requests reach green. Blue remains available for a defined rollback window before its resources are removed or reused. The colors are labels, not fixed lifecycle states; either environment can become the active production environment.

In cloud architectures, an environment might consist of virtual machines, container tasks, Kubernetes workloads, configuration, and supporting infrastructure. The environments need equivalent behavior and sufficient isolation, but they do not necessarily require separate accounts, clusters, or databases. Infrastructure as code helps keep networking, permissions, health checks, and configuration consistent. Validate dependency access and business transactions as well as basic process health before promotion.

For example, an Amazon ECS application can run its current and replacement task sets behind separate load balancer target groups. A deployment workflow starts the replacement tasks, waits for health checks, optionally exposes a test listener, and then shifts production traffic. With Amazon EKS, engineers can run separate Deployments for the two versions and switch a Kubernetes Service selector or ingress routing configuration. A Kubernetes rolling update is not automatically blue-green: it normally replaces replicas incrementally rather than retaining two separately promotable versions.

Each environment should satisfy the application's Availability Zone resilience requirements independently. Distribute tasks or pods across zones and ensure the receiving environment can handle production traffic with the required failure headroom. Check compute quotas, IP address capacity, load balancer configuration, and autoscaling limits before creating the replacement. Duplicating application capacity temporarily increases cost, and shared databases or external APIs may experience additional load during testing and warm-up.

Blue-green deployment can also support a release between AWS Regions, but it does not itself provide multi-Region resilience. The destination Region needs working dependencies, secrets, certificates, sufficient capacity, and an appropriate data replication design. Define recovery time and acceptable data loss, account for replication lag, and control which Region can accept writes. DNS-based cutover is not instantaneous because resolvers and clients cache answers; routing changes also do not move established connections.

State is usually the hardest part of rollback. Both application versions may share a database, so use backward-compatible expand-and-contract schema changes and postpone destructive migrations until the rollback window closes. Switching traffic back does not reverse writes already made by the new version. Externalize session state where appropriate, drain connections deliberately, and handle background workers separately to avoid unintended concurrent processing or duplicate side effects.

Finally, define promotion and rollback criteria using error rates, latency, resource saturation, and business metrics. Retaining blue makes recovery faster only while it remains healthy, adequately provisioned, and compatible with current data. Blue-green describes the environment arrangement; canary and linear strategies describe gradual traffic exposure and can be combined with it. Neither the pattern nor an all-at-once routing change guarantees zero downtime, so test cutover, rollback, and failure behavior under realistic load.

Key aspects of Blue-Green Deployments

Blue-green deployments combine separate release environments, controlled routing, compatible state, sufficient capacity, and measurable rollback criteria to reduce deployment disruption.

Separate deployment and production exposure

Prepare the replacement environment without changing the environment currently serving users. Promote it only after health checks, integration tests, and operational readiness checks pass.

Controlled traffic cutover

Move traffic using load balancer routing, Kubernetes routing, or DNS changes. Account for propagation, connection draining, sticky sessions, and clients that retain existing connections.

Retained rollback environment

Keep the previous version healthy and available for a defined observation window. Traffic rollback is useful only if that version can still process current data and safely interact with shared dependencies.

State and schema compatibility

Design database migrations, session handling, and message consumers for a period when both versions exist. Application rollback does not automatically undo database changes or external side effects.

Independent resilience and capacity

Provision each environment to meet production availability and scaling requirements, including placement across Availability Zones. For cross-Region promotion, validate dependency availability, data replication, and write ownership before switching traffic.

Observable promotion gates

Use automated tests and measurable thresholds for errors, latency, and business outcomes to decide whether to promote or roll back. Include a post-cutover observation period before retiring the previous environment.

Cloud services for Blue-Green Deployments

Amazon ECS or Amazon EKS supplies the container runtime for the two application versions, while Elastic Load Balancing provides health-aware application routing. AWS CodeDeploy can coordinate supported ECS blue-green deployments; EKS uses Kubernetes routing and deployment automation instead. Amazon Route 53 can move DNS traffic between environment endpoints, including across Regions, with caching constraints. Amazon CloudWatch provides signals for promotion gates and rollback decisions. Together, these services support controlled release transitions, but engineers must still design database compatibility, session handling, multi-AZ capacity, and cross-Region data consistency.

AWS CodeDeploy image AWS CodeDeploy

CodeDeploy orchestrates blue-green deployments for supported compute platforms, including Amazon ECS. For ECS, it coordinates replacement task sets, load balancer traffic shifting, validation hooks, and configured rollback behavior; it does not manage Kubernetes blue-green deployments on Amazon EKS.

Open AWS CodeDeploy →
Amazon Route 53 image Amazon Route 53

Route 53 can change DNS routing between environment endpoints, including endpoints in different AWS Regions. Weighted routing supports gradual exposure, but DNS caching means traffic movement and rollback are not immediate or precisely proportional at the request level.

Open Amazon Route 53 →
Amazon CloudWatch image Amazon CloudWatch

CloudWatch supplies metrics, logs, and alarms for evaluating release health before and after cutover. Deployment automation can use alarms to stop or roll back a release, but the previous environment must remain available and data-compatible.

Open Amazon CloudWatch →