1
votes

My use case: I have a web application served by an Elastic Load Balancer which is in front of 1 EC2 instance. The architecture aims to simulate a Blue/Green deployment flow, meaning that I will turn on a second instance when I need to update code and switch the one my ELB is pointing at.

Let's assume Instance-A has the current version of my application, my ELB is routing traffic to that instance since it's the only one available. I want to push updates to my app, so I deploy a new version of my application on Instance-B (turn on instance-B and deploy new version of code). Meanwhile any user visiting my application will still be routed to Instance-A and have a session created for until I make the switch.

Once Instance-B is deployed and available with the newer code, how can I ensure that the ELB will send new traffic only on Instance-B, and keep old traffic (previous users and their session) on instanceA until I deregister the latter from the load balancer?

Hope this makes sense, I'm aware this architecture design is not the right implementation of Blue/Green Deployment. But due to the size of my application and the budget, I would like to limit the number of instances I'm using.

Thank you for your help.

1

1 Answers

1
votes

Ok if you are using a classic ELB you need to create and stickiness policy for the ELB you could find detailed instructions here https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-sticky-sessions.html

If you are using ALB or application load balancers is almost the same but in the sticky policy is over the target group https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-target-groups.html#sticky-sessions

If you want to improve your blue/green deployment strategy would be better to use Route53 to make the switch and the cost is very low

I hope this helps