Zero Downtime Deployments
In this article, we will cover ...
Zero Downtime Deployments
Zero downtime deployments are a set of practices and techniques that allow teams to release new features and fixes without interrupting the service. Two of the most popular strategies for achieving this are Blue/Green and Canary deployments. Let's delve deeper into these methods.
Zero downtime deployment, as the name suggests, is a deployment strategy that ensures the system remains available to users even when updates are being rolled out. This is crucial for businesses that can't afford any service interruption, such as e-commerce platforms, financial services, and critical infrastructure. Mission critical applications in such scenarios must be mandated to follow these deployment patterns to ensure high availability.
1. Blue/Green Deployment
The Blue/Green deployment strategy involves having two separate environments: Blue (current production) and Green (new version).
How it works:
The Blue environment runs the current version of the application and serves all user traffic.
The new version of the application is deployed to the Green environment.
Once the Green environment is tested and ready, the traffic is switched from Blue to Green.
The Green environment becomes the new production, and the Blue environment is kept as a backup.
Advantages:
Instant rollback: If issues arise in the Green environment after the switch, traffic can be immediately rerouted back to the Blue environment.
Predictable releases: Since the Green environment can be thoroughly tested before the switch, there's a higher confidence in the deployment.
When to use:
Functional changes: Changes that have to be implemented to all users at the same time
Challenges:
Resource intensive: Requires maintaining two environments, which can be costly.
Database synchronization: If the application has a database, ensuring data consistency between Blue and Green environments can be challenging.
2. Canary Deployment
Named after the "canary in a coal mine" concept, Canary deployments involve releasing the new version to a small subset of users before rolling it out to everyone.
How it works:
The new version of the application is deployed alongside the old version.
A small percentage of user traffic is directed to the new version, while the majority still access the old version.
Adequate soak time must be allowed to observe the behavior before incrementally rolling out the change to the next part of the environment
Performance and feedback from the canary users are monitored.
If the new version performs well, it's gradually rolled out to more users until everyone is on the new version.
Advantages:
Reduced risk: Issues can be detected with a small user base, preventing widespread impact.
Gradual rollout: Allows for monitoring and adjusting the deployment process based on real-world usage.
When to use:
Non Functional Changes: Infrastructure and non-functional changes
Challenges:
Complexity: Managing multiple versions simultaneously can be complex.
Inconsistent user experience: Different users might have different experiences during the rollout phase.
3. Which to Choose?
The choice between Blue/Green and Canary deployments depends on the specific needs and constraints of a project:
Resource Availability: If resources (like servers and databases) are a constraint, Canary might be a better choice.
Risk Tolerance: For critical applications where even minor issues can have significant impacts, Blue/Green might be preferable due to its instant rollback capability.
Feedback Needs: If you want to gather user feedback on new features, Canary deployments offer a structured way to do so.
4. Must Reads
This article - https://martinfowler.com/bliki/BlueGreenDeployment.html
Zero downtime deployments are essential for businesses that prioritize service availability. Both Blue/Green and Canary deployments offer robust strategies to achieve this, but the choice depends on the specific needs of the project. By understanding the nuances of each method, teams can ensure smooth and reliable software releases.