Unleash

Blue-Green Deployments: How and What

Blue-Green deployments are a practice that works in tandem with feature flags, our favourite topic here, let’s dive in.

What is blue-green deployment?

The idea of blue-green deployment is pretty straightforward: It’s a deployment where two identical production environments are set up, which we call “blue” and “green.”

The blue environment runs your current software version, while the green one is where you test and validate your next versions. This setup aims to give you a safety net if things go wrong.

 

Overview: the blue-green deployment process

You start with all your traffic going to the blue environment, which has your current live (and hopefully stable) version. When you release a new version, you deploy it first to the green environment.

Next, you test the green environment thoroughly. If everything looks good, you start gradually shifting traffic from blue to green. You keep a close eye on things during this process.

If all goes well, you eventually move all traffic to green and can retire the old blue environment. But if problems crop up, you can quickly switch back to the blue environment while you sort things out and work on a fix.

Once the fixed version has been tested in the green environment and proven stable, it can be deployed to the blue environment and the process can be repeated for future releases.

The advantages of blue-green deployment

Blue-green deployment has a few advantages. It’s great for testing new versions in a real production environment and lets you quickly roll back if something goes wrong.

On top of the regular “gradual roll out”, some teams use it for A/B testing, comparing two versions side-by-side. And it can even serve as part of a disaster recovery strategy, giving you a standby environment ready to go.

That ability to quickly roll back to a known good state is a big safety net. And being able to effectively test in a production environment before fully deploying to it can help catch issues that might not show up in staging.

Best practices for blue-green deployment

When implementing blue-green deployments, the goal you’re working towards is seamless rollbacks. We recommend to automate the process as much as possible to minimize the impact of human error.

Ensuring parity between your blue and green environments is also a requirement. This strategy has no reason to exist if that’s not the case.

Lastly, don’t skimp on monitoring and logging to make sure you can see what’s happening.

The challenges with blue-green deployment

Like everything in software, there are no solutions, only trade offs. Managing two production environments adds complexity.

  • Blue/Green deployments require twice the resources, which increase infrastructure costs.
  • Blue-green deployments are designed for significant updates and revisions. If you only need to make a small change to your app, this deployment strategy may be too much.
  • Replicating a production environment can be complex, especially when working with microservices.
  • The green instance must be tested and monitored thoroughly before it can be released to production.

Using feature flags with blue-green deployment

We love feature flags here at Unleash, and you can integrate them into blue-green deployments.

What you’ll do is implement the flags in both blue and green environments. That lets you gradually activate and test new features in the green environment before the full traffic switch. If there are problems, you can quickly disable specific flags without rolling back the entire deployment. After switching to green for a while, you can start to disable feature flags.

Conclusion

Blue-green deployment can be a powerful strategy, and it works really well with feature flags. It’s not a silver bullet, but it’s useful if you want to reduce the risks associated with large deployments.

Share this article