2

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.

Steve D
  • 41
  • 1
  • 5

1 Answers1

1

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

Douglas Lopez
  • 396
  • 3
  • 4
  • Thank you @douglas for you reply, but it does not cover my use case. I updated my question, as it was not well described. – Steve D Oct 12 '18 at 01:05
  • Ok I got It, well with the sticky session policy for the application load balancer you could set up a time to keep the session with the same target using the attribute "stickiness.enabled and stickiness.lb_cookie.duration_seconds" but I'm Afraid this does not guarantee for more time than 7 days, for your use case the best approach if you need more than 7 days is to use other solution like Netflix Zuul and set up an ZuulFilter rule https://github.com/Netflix/zuul/wiki/Writing-Filters – Douglas Lopez Oct 12 '18 at 03:17
  • But I'm afraid is too complex scenario, you need a way to identify the user session and have the logic in the application level to do that – Douglas Lopez Oct 12 '18 at 03:18