What is blue-green deployment strategy?
Yep, it’s just another name for a continuous delivery strategy which involves gradual movement of traffic to a new service. Think of it as an application release model where two identical software/services are deployed, one being the old one and the other one being the new one. A small amount of traffic is first routed to the new software, and tested for issues. If no issues occur then the switch is made completely.
The old version is generally called the blue environment and the new version is known as the green environment.
Please note that this deployment strategy involves parallel deployment of the green and blue node.
When to use this strategy?
- If you have a cloud native application and update is needed to be pushed real time regardless of the count of the current number of users without.
- When downtime needs to be minimized
When Not to use this strategy?
- When database schema changes are too complex to decouple from code making it difficult to share data across applications
- If the software uses some type of flags to control it’s features which in turn can run alternate subroutines. Avoiding this deployment strategy would be a good choice in this case.
How to blue-green deployment strategy?
Let us understand this with a simple image:
Practical application of this blue-green deployment strategy
You have developed a simple cloud native application which is a mobile game where users earn points by tapping multicolored balloons flying across the screen. (If you are not bugged by snapping bugs, try the game ant smash on playstore). The game’s backend is deployed across various nodes.
After the initial release, a lot of users start playing the game and a lot of transactions are being logged every minute. Now in this scenario, you have two options, if you are to deploy a minor update to the application
- Either stop the server when the number of active users are less and then deploy the update or
- You can use a good deployment strategy which will allow you to make the migration, even while the users are active. The blue green deployment strategy is actually very helpful in this case.
The updated service is deployed on a clone of the original mode/server. The load balancer can now be configured to redirect the user’s next transaction through this new node. The old node can serve as a standby or can be used as green node in the next iteration of deployment.