49

What's the difference between a blue/green deployment and a rolling deployment? I always thought that a blue/green deployment was a sudden switch of traffic from the old version to the new version immediately.

This talk about Blue/Green deployment on AWS shows various different strategies to implement a blue/green deployment, but they also seem to match the definition of a rolling deployment.

Is a blue/green deployment a subset of rolling deployments?

Super Kai - Kazuya Ito
  • 22,221
  • 10
  • 124
  • 129
n00b
  • 5,843
  • 11
  • 52
  • 82
  • Rolling deployments are staggered. Blue/green is a sudden switch after canary testing. – Matthew Schuchard Feb 21 '17 at 12:57
  • That's my understanding as well, but if you watch the AWS video by the solution architects their solutions for blue/green aren't sudden and are gradual hence my question. – n00b Feb 22 '17 at 22:04
  • 1
    You have to realize a lot of this is opinion and theory. The idea for both of these is that you minimize production downtime for an application. You should make sure you are always able to "see the forest for the trees" here. Get the idea of how both of these work and then adapt them to best fit your environment. – Matthew Schuchard Feb 22 '17 at 22:24
  • Usecase matters while choosing the type of the deployment. For stateful applications, green/blue model is preferred where the entire application maintains the state of the system. – user4202236 Mar 30 '22 at 20:56

4 Answers4

53

I have written an essay on this topic here: http://blog.itaysk.com/2017/11/20/deployment-strategies-defined

In my opinion the difference is whether the new version is applied by replacing instances in the existing setup (in the case of rolling upgrade), or a completely isolated setup is created for the new version (in the case of Blue/Green). In my opinion Blue/Green is the safest strategy and is better in most cases for production deployments. Read the post for a detailed comparison.

itaysk
  • 5,852
  • 2
  • 33
  • 40
  • For production deployments, blue green is better? I think docker based production environments are more approachable for rolling upgrade – overexchange Mar 15 '20 at 02:17
  • 3
    This answer is quite old but I would still say the b/g is safer if it works for you. You can do blue/green with docker: if you had two containers serving traffic and you created a new couple of containers to serve the new version, and then swapped the traffic so not the new couple is active, that's b/g. But if you had two containers and you upgraded one at a time, then this is rolling. – itaysk Mar 15 '20 at 10:37
  • It is not just the number of containers, we run containers in AWS vpc. B/G will create call those resources (subnets/security groups etc...) Which is unnecessary... Isn't it? – overexchange Mar 15 '20 at 14:36
  • if you meant to say that there will be redundancy - then yes this is how b/g works. for the duration of the migration you will need to run (and pay for) both versions of the application. However, what is the granularity of "the application" is up to you to decide, and this is also discussed in the blog post. it doesn't have to be the entire network environment. if you prefer, it could be at the scope of "a service", which may be just a couple of containers and a virtual load balancer. upgrading a single service in isolation may be easy or hard depending on how well your system is designed. – itaysk Mar 15 '20 at 20:08
49

In Blue Green Deployment, you have TWO complete environments.

One is Blue environment which is running and the Green environment to which you want to upgrade. Once you swap the environment from blue to green, the traffic is directed to your new green environment. You can delete or save your old blue environment for backup until the green environment is stable.

In Rolling Deployment, you have only ONE complete environment.

Once you start upgrading your environment. The code is deployed in the subset of instances of the same environment and moves to another subset after completion.

So both are different in various factors and you need to choose the deployment model based on the scenario. Blue/green deployment is not a subset of rolling deployments.

Sarat Chandra
  • 5,636
  • 34
  • 30
14

Blue-Green Deployment:

There are two environments, Blue environment which is "old" and contains one or more applications(instances or containers) and Green environment which is "new" and contains one or more applications(instances or containers).

Then, 100% traffic is quickly switched from Blue environment to Green environment at once as shown below:

enter image description here This image above is from https://www.encora.com/insights/zero-downtime-deployment-techniques-blue-green-deployments originally created by the company "Encora"

enter image description here This image above is from https://avikdas.com/2020/06/30/scalability-concepts-zero-downtime-deployments.html originally created by Avik Das

In addition, there is Canary Deployment which is gradual way of Blue-Green Deployment. In this case of Canary Deployment, 100% traffic is gradually switched from Blue environment to Green environment taking a longer time(30 minutes, hours, or days) than Blue-Green Deployment as shown below:

enter image description here This image above is from https://www.encora.com/insights/zero-downtime-deployment-techniques-canary-deployments originally created by the company "Encora"

Rolling Deployment:

There is one environment which contains one or more "old" applications(instances or containers).

Then, one by one, one or more "old" applications(instances or containers) are replaced with one or more "new" applications(instances or containers) as shown below:

enter image description here This image above is from https://avikdas.com/2020/06/30/scalability-concepts-zero-downtime-deployments.html originally created by Avik Das

Henry Ecker
  • 34,399
  • 18
  • 41
  • 57
Super Kai - Kazuya Ito
  • 22,221
  • 10
  • 124
  • 129
  • Could you explain what an environment stands for please ? If I need to upgrade a specific microservice in my cluster I would target the deployment of that microservice so the only option I can choose would be Rolling Deployment as I'm not able to see in this case what could be an environment. – javaxiss Jul 23 '22 at 10:42
0

If you are considering Blue-Green Deployment, why don't you try

https://github.com/Andrew-Kang-G/docker-blue-green-runner

With your project and its only Dockerfile, Docker-Blue-Green-Runner handles the rest of the Continuous Deployment (CD) process with Consul. Nginx allows your project to be deployed without experiencing any downtime.

The thing is that samples come with PHP, Java and Node.js. And as it is created with Shell Script, it is comparatively easier to use and look into source codes.

Kang Andrew
  • 330
  • 2
  • 14