
Answer-first summary for fast verification
Answer: Disable session affinity (sticky sessions) on the ALB
## Explanation When traffic seems to favor one EC2 instance behind an Application Load Balancer (ALB), this is typically caused by **session affinity (sticky sessions)** being enabled. Here's why: ### How Sticky Sessions Work - **Session affinity** ensures that requests from a particular client are always routed to the same target instance. - This is useful for applications that store session data locally on the instance. - However, it can lead to **uneven traffic distribution** if some clients generate more requests than others. ### The Problem - The question states that traffic "favors one EC2 instance" - this is a classic symptom of sticky sessions. - When sticky sessions are enabled, all requests from a particular client go to the same instance, which can create load imbalances. - This results in latency for some requests because the overloaded instance cannot handle all traffic efficiently. ### Why Other Options Are Incorrect **B. Replace the ALB with a Network Load Balancer** - Network Load Balancers (NLBs) operate at Layer 4 and don't support session affinity at the application layer. - However, replacing the ALB is unnecessary and disruptive when the issue can be resolved by simply disabling sticky sessions. **C. Increase the number of EC2 instances in each Availability Zone** - Adding more instances doesn't solve the root cause of uneven distribution. - The traffic would still favor certain instances due to sticky sessions. - This would be an inefficient use of resources. **D. Adjust the frequency of the health checks on the ALB's target group** - Health check frequency affects how quickly the ALB detects unhealthy instances. - It doesn't address traffic distribution patterns or session affinity issues. ### Best Practice - **Disable sticky sessions** unless your application specifically requires them. - For applications that need session persistence, consider using **Amazon ElastiCache** or **Amazon DynamoDB** to store session data externally. - This allows for true load balancing across all instances while maintaining session state. ### Additional Considerations - If the application requires session persistence, you could: 1. Use shorter sticky session durations 2. Implement client-side session storage 3. Use distributed session stores - Monitor the load distribution after disabling sticky sessions to ensure traffic is evenly distributed.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
A company is building a new furniture inventory application. The company has deployed the application on a fleet of Amazon EC2 instances across multiple Availability Zones. The EC2 instances run behind an Application Load Balancer (ALB) in their VPC.
A solutions architect has observed that incoming traffic seems to favor one EC2 instance, resulting in latency for some requests.
What should the solutions architect do to resolve this issue?
A
Disable session affinity (sticky sessions) on the ALB
B
Replace the ALB with a Network Load Balancer
C
Increase the number of EC2 instances in each Availability Zone
D
Adjust the frequency of the health checks on the ALB's target group