Blue/green deployment is a technique for releasing applications by shifting traffic between two identical environments running different versions of the application. Blue/green deployments can mitigate common risks associated with deploying software, such as downtime and rollback capability. With weighted target groups, each target group can be a version of the application. You can set weights appropriately to get the desired distribution between the blue/green versions and rollback to blue if the results in green are not satisfactory.
If you want to move your on-prem infrastructure to the cloud in a gradual manner with a period where application is running both on the on-prem datacenter and cloud (hybrid). With weighted target groups, while having the same entry point to your application, using IP as target feature, you can have one target group which can be a collection of your on-prem instances while the other comprising of cloud compute (EC2, ECS etc.). You can gradually move the traffic to cloud by adjusting weights.
Let's say we are moving our web page to a darker theme (Green Version) from the current bright theme (Blue Version). We want to do a gradual roll out to the new theme without any downtime. Therefore, we follow the blue/green deployment pattern to keep both versions running in the production environment and gradually shifting traffic to the desired version by adjusting the weight of each target group.
We can use DNS traffic distribution to mimic blue/green deployments for our web page. However, there are some drawbacks about this solution such as DNS caching, provisioning and managing additional capacities etc. Now, with ALB supporting weighted target groups, we can achieve seamless blue/green deployments using APIs to automate traffic weighting and rollback. No need to provision multiple load balancers for the same application anymore”
1. When you click the button above, a HTTP request is sent to the "exampleloadbalancer" Application Load Balancer with URL path -- "albwtg_detail"
2. The "exampleloadbalancer" Application Load Balancer has a rule configured to route requests with path of "albwtg_detail" to two Lambda Target Groups
3. One Lambda target group has bright-theme web page deployed (Blue). The other Lambda target group has dark-theme web page deployed (Green)
4. For demonstrating purpose, we configure both target groups with the same weight
5. The web page itself refresh every 30 seconds. Therefore, you might see different versions after a refresh