Fiifi Baidoo
Baidoo

Baidoo

Blue/Green Deployment: Minimize Downtime When Deploying New Code

Blue/Green Deployment: Minimize Downtime When Deploying New Code

Fiifi Baidoo's photo
Fiifi Baidoo
·Jun 26, 2022·

3 min read

Subscribe to my newsletter and never miss my upcoming articles

Play this article

Deploying new code can be a tricky process. You want to make sure that the new code is working correctly, but you also don't want to take your website or application down for too long. This is where blue/green deployments come in handy. With this technique, you have two identical production environments - one called "blue" and the other called "green". New code is deployed to the "green" environment, and once it has been verified to be working correctly, the traffic is switched over to the "green" environment. If there are any problems with the new code, it can quickly be rolled back to the "blue" environment. Thanks to blue-green deployments, you can minimize downtime when deploying new code!

What is a Blue/Green Deployment

Blue/Green, or red-black deployment, is a technique for releasing applications by slowly shifting traffic between two identical environments running different versions of the application. Blue/green deployments help you update your applications without having to stop working. This way, you don't have to worry about being down for a long time or not being able to go back to the old version of the application.

Blue:green architecture.png

The current application version, which is blue, is compared to the new application version, which is green. Only one variant of the software is operational at a time. The blue deployment receives traffic while the green deployment gets built and tested. After you're finished testing, you route traffic to the new version.

After the deployment is finished, you have two options: retain the blue deployment for a possible rollback or delete it. You may also deploy a newer version of the app on these instances. If that's the case, the present (blue) environment serves as a staging area for the next release.

The main goal of using blue/green deployments is to minimize downtime, but there are some benefits and considerations for a Blue/green strategy.

Benefits

  • Minimal downtime – since only one environment is live at any time, there is no need to take the application offline for maintenance or upgrades.
  • Easy rollback – if there are problems with the new code, it can quickly be rolled back to the old code in the "green" environment.
  • Test in production - Blue/green deployments also make it easier to test in production, since you can route traffic to the new version without affecting users.
  • A/B testing - Blue/green deployments can be used to A/B test new features by slowly rolling them out to a subset of users.

Considerations

  • Increased complexity – setting up two identical environments can be complex and time-consuming.
  • Increased storage requirements – since the two environments need to be identical in order not to lose information, you will need to duplicate your data (user session and other data) across both environments in real-time.

Blue/Green Deployment on Google Cloud Platform

GCP offers a variety of tools and services that can help you deploy and implement a blue/green deployment pattern. App Engine, Google Kubernetes Engine (GKE), Compute Engine Managed Instance Groups and Cloud Run are some of the services that offer this type of deployment.

Google App Engine, Cloud Run and Google Kubernetes Engine support Blue/Green Deployment out of the box on the Google Cloud Platform. If you're using Kubernetes Engine, you can use GKE to implement Blue/Green deployments to update your applications without taking them offline.

You can use Cloud Build to deploy blue/green strategy on GCP. With Cloud Build, you can create a build pipeline that automates the process of building, testing, deploying, and routing traffic to your application. You can use Cloud Logging and Monitoring to monitor your application's performance once they are deployed.

Blue/green deployments are a great way to minimize downtime when deploying new code. Thanks to blue/green deployments, you can quickly roll back to the old code in the "green" environment if there are any problems with the new code.

 
Share this