Blue-Green vs. Rolling Deployments: Pros + Cons & Why Not Both?   featured image

Having an efficient and intelligent deployment pattern is integral for developing modern software.

Blue-green and rolling deployments are two of the most commonly-used methods for zero-downtime development. The most significant difference between these two is that blue-green deployments have two environments, whereas rolling deployments have one. Rolling deployments follow a staggered delivery pattern that gradually replaces instances of the existing environment with updated versions. Meanwhile, blue-green deployments involve creating a rigorously-tested second environment before completely shifting the current instance to the new environment. 

Rolling deployment patterns are also called gradual deployments. When an update is ready, a rolling pattern slowly replaces all current instances of an application with the updated version.

This article explores both blue-green and rolling deployments, their options, their benefits and challenges, and some tools that support both methods.

Pros and Cons of Rolling Deployments

This section explores some of the benefits and difficulties of using a rolling deployment pattern.

Monitoring and Rollback

One of the most significant benefits of a rolling pattern is the ability to perform health checks during an update frequently. Health checking allows us to monitor the rollout as it happens. Since a rolling pattern is gradual, we can monitor our new environments while the old ones are still updating. So, we can quickly stop the rollout and roll back to a previous version during this process if we encounter an issue.

Low Service Use

Containing rolling patterns within one environment reduces the number of services running throughout development. Let’s say our application uses five services concurrently to stay online. During a rolling deployment, we would continue to use just those five services as one instance each. In contrast, a blue-green deployment pattern would use the same five services but as two instances each during an update. Many services might reach their connection limits if the number of instances doubles in a quick burst.

While rolling patterns are great, they also have a few downsides that we should take into consideration.

Speed

One of the biggest challenges of working with gradual patterns is speed. Incremental deployments rely on algorithms that often require lots of time to implement updates instance by instance. This method is much slower than the instant update mechanism of a blue-green pattern.

Backward Compatibility

Since our updated code and old code exist in the same environment during an update, some users access one version of the application, and some access the other. This situation means that backward compatibility is a requirement when using a rolling pattern.

Use Cases

Rolling patterns are preferable in quite a few situations. For example, maybe your team only has space for one environment running at any one time. Or, you’d like to avoid using a load balancer for your user routing. Both of these situations would benefit most from a rolling pattern.

Overall, rolling deployment patterns are an excellent option for modern software development. Now, let’s take a closer look at blue-green deployment patterns.

Pros and Cons of Blue-Green Deployment

A blue-green deployment pattern switches all user traffic over to the new version with no downtime when an update is fully ready. Switching traffic works by having two environments in production: one with the live code and one with the updated code. Blue-green patterns use a router or load balancer to manage user routing and switch between environments during an update. 

Let's explore some benefits and challenges of using a blue-green deployment pattern.

No Maintenance Windows

With blue-green patterns, we don’t need to plan maintenance windows and downtime to deploy an update. This lack of downtime is also true of rolling patterns. But, blue-green patterns reroute all users to the updated version at once instead of over time.

Safety

Blue-green patterns tend to be much safer because the updated instance doesn’t come into contact with any currently running instances. This isolation protects the working live version from breaking and reduces the likelihood of a rollback. It also creates a benefit where backward compatibility isn’t necessary for applications on a blue-green pattern.

Blue-green patterns have many benefits and significant use cases. But, as with rolling patterns, they also have their unique challenges to overcome.

High Infrastructure Costs

With two environments running and multiple instances of any services used, blue-green patterns tend to have much higher infrastructure costs than other deployment methods. This system often requires essentially double the resources of a rolling pattern.

More Database Management

Blue-green patterns require more careful consideration when it comes to database management. Managing your database or databases is more complicated when you have parallel production environments. Any changes made in an update must appear in both environments for the pattern to work correctly.

Let’s say that the updated environment requires a database table named RED, but the live environment is currently working with that same table named BLACK. This naming poses an issue as one environment would be incompatible with the other for some time.

Use Cases

Blue-green patterns have more general use cases than rolling patterns simply due to their versatility. This pattern is best to use when you need low downtime and fast updates. As mentioned before, blue-green patterns require double the resources of a rolling pattern. A blue-green pattern may be perfect for your team if a load balancer is part of your deployment workflow. 

Proper deployment requires the right tools and systems. Let’s examine some of LaunchDarkly’s offerings that can enhance our next deployment cycle.

Helpful Deployment Tools

As developers, we need the right tools to create the best software that we possibly can. Deployment patterns play a huge role in many aspects of development, including our customer relations and our development schedules. So, the tools we choose have an impact far beyond our development environment.

Feature flags and feature management can control whether certain features are live, enabling us to choose which users see which features selectively. Feature flags also act as a “kill switch” for risky code. 

For example, we can use the kill switch feature in a rolling pattern to lock down our update when pushing dangerous code and divert users to the previous live version. Meanwhile, in a blue-green pattern, we can use feature flags to control which users see certain features, giving us more control over our testing and rollout. Through feature flags, LaunchDarkly helps significantly minimize risks during deployment and provide a powerful way to test, deploy, and manage code.

Conclusion

We know that it is vital for development teams to have the most efficient process to create, maintain, and always deploy code. Both rolling and blue-green patterns can be great tools for deploying code. 

Rolling patterns gradually update live instances to an updated version, with no downtime and low resource use. You maintain blue-green patterns with two development environments in production, switching from one to the other as each update completes. These blue-green patterns are great for safety and speed.

Related Content

More about Best Practices

June 9, 2022