Skip to main content
This lesson explains blue-green deployments for multi-service applications on AWS: what they are, why they help, common implementation patterns, pipeline flow, monitoring and rollback, and frequent pitfalls to avoid.

What is a blue-green deployment?

  • Maintain two parallel environments: the active production environment (blue) and a staged replacement (green).
  • Deploy the new version into green, validate it, then switch user traffic from blue to green.
  • Benefits:
    • Near-zero downtime
    • Fast, reliable rollback (keep blue until green proves stable)
    • Strong testability and verification of the production-ready artifact
    • Reduced configuration drift by treating environments as immutable
Two operational requirements are essential: a mechanism to shift traffic and a way to validate health before shifting. Below are common AWS approaches and recommended practices.

Common AWS approaches for traffic shifting

A diagram titled "Update DNS Routing With Amazon Route 53" showing user traffic going through Route 53 and being routed to Blue and Green environments, each with load balancers distributing to instances in AZ1 and AZ2.

Route 53 traffic shifting

  • Route 53 supports weighted record sets so you can migrate traffic progressively (for example 0% → 10% → 25% → 50% → 100%).
  • It works for single instances, instance groups, Auto Scaling groups, ECS services, EKS clusters, Elastic Beanstalk, and other resources that Route 53 can resolve.
  • Note: DNS TTLs and client DNS caching affect how quickly weight changes take effect.

Auto Scaling group swap behind a load balancer

  • Create green ASGs and attach them (or their target groups) to the Load Balancer while blue still serves production.
  • When green passes validation, change the LB target to green (or set weights on target groups).
  • Keep blue available for a quick rollback, or terminate it after you’re confident in green.
An AWS architecture diagram titled "Swapping Auto Scaling Group Behind Elastic Load Balancer" showing users routed via Route 53 to an ELB, which forwards traffic to two Auto Scaling Groups inside the AWS Cloud (one empty and one with instances).

AWS CodeDeploy blue/green deployments

  • CodeDeploy automates blue/green workflow, supports traffic shifting strategies, and runs health checks during deployment.
  • Integrates with Auto Scaling groups, Amazon ECS, and Lambda alias-based deployments.
  • Supports automated or manual cutover and rollback triggers.
A diagram of AWS CodeDeploy performing a blue/green deployment: the CodeDeploy service on the left routes to a Blue (Deployment Group A) and a Green (Deployment Group B) environment (each showing instances), with an "Automated/Manual cutover" step.
  1. Developer commits code to VCS.
  2. Build stage (e.g., AWS CodeBuild or equivalent) produces immutable artifacts (images, packages).
  3. Pipeline deploys artifacts to green (ECS task set, Auto Scaling group, Lambda alias, etc.).
  4. Health checks and smoke tests validate green (API checks, integration tests, synthetic transactions).
  5. Shift traffic via Load Balancer (target group swap/weight) or Route 53 (incremental weights).
  6. Keep blue as a rollback target until green is confirmed stable; then decommission blue as appropriate.
Automate the pipeline and use a consistent health-check mechanism (load balancer, Route 53 health checks, or application-level probes). Configure automated rollback triggers based on health checks and critical metrics to reduce mean time to recovery.

Gradual (canary) rollouts

  • Canary rollouts let you route a small percentage of traffic to green initially (for example, 10% every 10 minutes) and increase as confidence grows.
  • Monitor key signals (latency, error rate, throughput, logs) before increasing traffic increments.
  • Canary strategies pair well with feature flags and observability dashboards.
A presentation slide titled "Blue/Green Deployments on AWS – Best Practices" listing items like automate deployment pipelines, ELB, Route 53, health checks, canary/gradual rollouts (highlighted), rollback mechanisms, and monitoring. The right side shows a small icon of a settings panel with an upward bar chart and target symbol.

Monitoring and rollback

  • Continuously monitor application metrics (latency, error rates, user-facing KPIs), infrastructure metrics, and logs during each rollout step.
  • Define clear automated rollback criteria (e.g., error rate spike > X% or latency above threshold for Y minutes).
  • Have a documented manual fallback plan to switch back to blue quickly if automation fails.
A presentation slide titled "Blue/Green Deployments on AWS – Best Practices" with a left-hand list of tips (automate pipelines, use ELB and Route 53, health checks, canaries, rollbacks). The right side highlights monitoring tools with Amazon CloudWatch and Amazon CloudFormation icons and a "Monitor Metrics & Logs" button.

Common failure modes and how to avoid them

  • Provisioning failures: green environment fails to provision. Mitigation: CI/CD should validate infra provisioning in an isolated stage.
  • Permission errors: missing IAM permissions for deployment. Mitigation: least-privilege IAM roles and test role permissions in staging.
  • Application start-up failures: environment differences (config, secrets, env vars) break startup. Mitigation: ensure configuration parity and secret management parity between blue and green.
  • DNS or load balancer misrouting: incorrect rules or cached DNS entries cause unexpected traffic distribution. Mitigation: validate routing rules and account for DNS TTL/client caching.
  • Incomplete infrastructure duplication: not all resources (databases, caches, or feature flags) were duplicated or toggled correctly. Mitigation: run pre-cutover checks and maintain infrastructure-as-code templates to ensure parity.
A diagram illustrating blue/green deployments that highlights a common failure: DNS or load balancer misrouting via Route 53. It shows users routed to either the Blue or Green environment (each with AZ1/AZ2 and instances) and a warning where misrouting occurs.
Pay careful attention to infrastructure parity and routing configuration. DNS TTLs, client-side DNS caching, or misconfigured load balancer target groups can cause rollbacks or percentage-based shifts to behave unpredictably. Test rollback procedures regularly.

Applicability and considerations

  • Blue-green works across many AWS services:
    • Elastic Beanstalk
    • Lambda (via aliases)
    • Amazon ECS (task set blue/green)
    • Amazon EKS (requires explicit traffic-shifting using Kubernetes Services, Ingress controllers, or a service mesh)
    • EC2 + Auto Scaling groups
  • EKS does not provide native blue/green traffic shifting; you must implement it using Kubernetes primitives or a service mesh (e.g., Istio) or an external load balancer.
A slide titled "Blue/Green Deployments – Common Failures" showing side-by-side Blue and Green environments with load balancers and AZ1/AZ2 instance groups. The diagram highlights "Incomplete Infrastructure Duplication" between the two environments.

Summary and best practices

  • Blue-green deployments provide safe, testable rollouts with minimal downtime and fast rollback capability.
  • Use automation (CI/CD), immutable artifacts, consistent health checks, and observability to drive deployment decisions.
  • Prefer load-balancer–based switching for immediate cutovers; use Route 53 when DNS-level control or cross-region routing is required.
  • Always design for environment parity, define rollback criteria, and consider DNS TTL and client caching when planning rollbacks or canary strategies.
Further reading and references: That concludes this lesson on blue-green deployments for multi-service applications.

Watch Video