When managing a few backend servers, it’s occasionally helpful that one customer (program) is constantly served by the same backend server (for session persistence for instance).
Utilizing a persistence by IP (with the ip_hash upstream module) is perhaps not a smart thought in light of the fact that there could be circumstances where a variety of programs are accompanying a similar IP address (behind proxies)and the load balancing system system won’t be reasonable.In this article I will describe how to enable sticky session in your application load balancer in aws.
In application load balancer you can enable sitcky session at the traget group level.
You can also set the duration for the stickiness of the load balancer-generated cookie in seconds.
Follow the below steps to enable the sticky session in aws application load balancer.
Enable Sticky Sessions Using The Console
1. Login to your aws account and open the Amazon EC2 console.
2. Choose the Target Groups under the Load Balancer, on the navigation pane.
3. Now select the target group
4. Go to the Description page and choose Edit attributes.
5. In the Edit attributes page enable the following:
- a. Select Enable load balancer generated cookies stickiness.
- b. Set the sticky duration specify a value between 1 second to 7 days.
- c. Now save