- Newest
- Most votes
- Most comments
Hi.
Did you enable sticky sessions on your target group? Is the cookie for sticky session set in the response from ALB with Set-Cookie?
As per my understanding load balancer generated cookie are managed by load balancer and we do not need to send cookie through client side.
Application Load Balancer is cookie-based and sticky. Your client will need to resend the set cookie from the server.
(Network Load Balancer provides sticky based on client IP address so you don't have to resend the cookie.)
iwasa answered your first question already. For the 2nd question:
But after sometime i see CPU load going down
After the new instance is InService in the ASG (AutoScaling Group) its Warmup timer will start (configured on the scaling policy). Once the warmup ends, the new instance will be counted towards the average group metrics. This mean if the first instance was still at 80% load, and the new instance is at 40% load, the average CPU metric will show up as 60%
How to tell if stickyness is working?
You can enabled access logs if this is an ALB and see where requests are landing; otherwise look at your application logs in the instance. But in general, if you have 5 clients on an instance, each with a sticky session; then those 5 will still all be on the first instance after the scale out (because of the sticky session). This is a big reason why you want to try and make applications stateless whenever possible and store session data off instance somewhere like EFS, RDS, etc.
Load will not be shared by new instance. So Average CPU usage will be same. So autoscaling will keep on launching
This isn't correct. The average CPU would go down with the new instance and launching would stop. For an extreme example, assume the first instance is at 80% and the new instance launched after that gets 0 load. Average would be (80 + 0)/2 = 40%, so scaling would stop
Hello @iwasa and @Shahad_C,
Thanks for the reply.
As per the suggestion, I checked in cookie received in response from ALB, It was having a cookie with name AWSALB and 7 days expiry period. As our scenario is we can't send cookie in request from client. I created a new environment with NLB with stickiness.
with NLB, no cookie is received and when CPU loading is above threshold new instance is launched. and CPU load is 0% on new instance. and keeps same on old instance. Average definitely came down of threshold as pointed out by @Shahad_C. Thanks for correcting. No new instance are launched after metrics goes down threshold. So stickiness is working with NLB.
However I checked earlier for ALB uses Round Robin by default. With stickiness probably that is not a good idea. for Network load balancer i want to use Least connection strategy. But NLB does not have any option to edit "Load balancing algorithm" in Attributes. which algorithm NLB uses for balancing by default, can't we edit this ?
Relevant content
- asked 9 months ago
- asked a year ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 months ago
- AWS OFFICIALUpdated 8 months ago
- AWS OFFICIALUpdated 4 months ago