1. Home
  2. CRO Dictionary
  3. Blue green deployment

Blue green deployment

Blue green deployment is a method for making software that uses two production environments. Blue & green, to make software deployment easier and safer.

Blue green deployment

What is blue-green deployment?

A “blue environment” and a “green environment” are used in the blue green deployment method of software development to make the software deployment process more straightforward and safer.

When new code is deployed, it is pushed to the environment that is not currently used. The two production environments are kept as similar as possible. A router can then be switched to point to the environment where the new changes are live after the new changes have been tested in production, resulting in a seamless cut-over.


Use cases for blue-green deployment

Rollbacks

Disaster recovery is one of the main advantages of blue-green deployments. Because there are two identical production environments, if new changes are implemented in one (let’s say the blue version), and any problems are found, a router can switch back to the other environment (the green version), which contains the previous version of the code, with no downtime.

Continuous delivery and integration (CI/CD)

Through automated testing and frequent code integration, continuous integration, a DevOps technique, aims to accelerate software development and get it live as soon as possible.

This objective can be achieved by using the deployment strategy known as “blue-green deployment,” which permits more code to be pushed to production while reducing the risk of new releases.

Production testing

Despite efforts to make the staging environment and production identical, the two have frequent minute differences. This might result in edge cases and bugs appearing only after the code was pushed into production.

By pushing new code into the actual production environment and monitoring how it performs, blue-green deployment enables testing in production before seamlessly introducing it to production traffic and actual users.

Deployment of canaries

Canary deployment is when new changes are rolled out to a select group of your user base instead of the entire user base. This small controlled test can be used to find any fatal errors in the new version of your code, acting somewhat like a canary in a coal mine.

By simply having the router direct a portion of your traffic to the new version of the code to see how it performs with live traffic, you can use blue-green deployment to perform such canary testing before rolling out the change to 100% of your users.

A/B testing

A/B testing is yet another potential application for blue-green deployments. In this use case, you would upload the updated code to the blue environment and direct fifty percent of user traffic there instead of the original green environment.

Following that, you can use statistical analysis to compare how the two environments fare in terms of your key performance indicators and monitor their performance.

Load balancing

Load balancing is another potential application for blue-green deployment. A router can easily balance traffic between the blue and green versions of the production environment because they are functionally the same if the blue/green deployment is set up so that the two production environments are on separate servers (rather than a virtual machine).


Example of a blue-green deployment

Consider a situation where your development team is working on a web application and wants to release a new feature. But they wanted to do so without downtime and with a seamless switch to the new code. You would set up two identical production environments in addition to your staging environment (a “blue version” and “green version”), with a router directing traffic to the green version.

After that, you can apply the fresh updates to the production environment’s blue version to test their effectiveness. If it turns out that specific bugs only exist in your production environment, you can easily switch back to development mode with no adverse effects on your users.

To conduct a canary test on actual users, you can start to direct a portion of your user traffic to the blue environment once you are confident in the performance of the new version of the application. If no problems are found, you can direct all your traffic to the new environment, resulting in a successful feature release.

Once the switchover has been made, you can easily route traffic back to the environment in the green that contains the older version of your code to carry out a simple rollback if any problems are found.

You can then copy the blue environment to the green environment to create two identical production environments once you are sure there are no problems with the new code. The development lifecycle can then continue, or if you notice a spike in usage, you can use the second server as a load balancer as necessary.


Blue-green deployment versus feature flags

Using feature flags or feature toggles is a different development strategy from blue-green deployment. New features and code are encapsulated in conditional code with feature flags so they can be remotely turned on or off.

As a result, developers can easily roll back features deployed to production without maintaining two production environments.

Feature flags can be used for targeted rollouts, where a feature is only enabled for a particular segment of your user traffic, in addition to simple on/off functionality.

This enables use cases like A/B testing and canary deployments without maintaining two production environments.

New interesting words

Interesting reads from Scribbleminds