How can the developer ensure that users stay signed in when the Auto Scaling group is scaled down?
Enable sticky sessions on the ALB target group.
Create an Amazon DynamoDB table. Configure the application to use the DynamoDB table to store session state such as login status.
Create an Amazon Elastic Block Store (Amazon EBS) volume. Use EBS Multi-Attach to attach the volume to all instances in the Auto Scaling group. Configure the application to use the volume to store session state such as login status.
Enable deregistration delay on the ALB target group.
Explanations:
Sticky sessions (also known as session affinity) can bind a user’s session to a specific EC2 instance. However, if the instance is terminated due to scaling down, the session will be lost.
Storing session state in a centralized system like Amazon DynamoDB ensures that session data is preserved across scaling events, even if EC2 instances are terminated.
Using Amazon EBS with Multi-Attach is not a suitable solution for session state management across Auto Scaling groups. EBS volumes are designed for persistent storage of block data, not shared session states.
Enabling deregistration delay ensures that traffic is routed away from instances during scaling events but does not preserve session state across instances. The session data can still be lost if not stored externally.