Skip to content →

Blue / Green Deployments

Deployment is the process of getting an application on to a server. The application can be as small as a single web server, or a larger stack that includes a web server, application servers, database, and a message queue. To deploy an app is to get all the pieces up and running on one or more computers.

There are a few different deployment strategies that people use; one of them is called Blue / Green (aka “A/B”) deployments.

This strategy shifts traffic from the old app to the new app while both apps are running in a production environment. The old app and the new app are usually very similar to each other. Perhaps the new app has a small bug fix that most users probably wouldn’t even notice. This is in the spirit of “deploy early, deploy often” and making small changes frequently.

The two versions should be on identical infrastructure (same amount of memory, CPU, etc) so there aren’t any unexpected behavior caused by underlying resources.

The shifting of traffic is implemented by configuring a routing mechanism that sits in-between a load balancer and the server. In Kubernetes, this can be a Service and you can route the traffic by changing the labelSelector. In AWS, this can be achieved by configuring a Load Balancer when you’re ready to switch from blue to green.

Traffic is flowing to either the blue app or the green app, but never both at the same time. Once the green app has been validated, then all traffic gets will be directed to it, leaving the blue app lonesomely blue and empty inside.

Benefits

  • No downtime
  • Can perform updates any time, even during peak usage
  • Can easily rollback to the old app if the new app breaks
  • The infrastructure hosting the old app can be used as a staging environment for the next release, or as redundancy for the new version in case of disaster recovery

Published in Today I Learned