Skip to main content
Nauman Munir
Back to Projects
Case StudyE-CommerceInfrastructure as Code

Enhancing Session Consistency with Sticky Sessions in AWS ALB

Improved user experience and conversion rates for an online retail platform by enabling sticky sessions on AWS Application Load Balancer, ensuring consistent session behavior.

4 min read
3 weeks

Technologies

AWS Application Load Balancer (ALB)Duration-Based Sticky Sessions (AWSALB Cookie)Cross-Zone Load BalancingEC2 Auto ScalingCORS ConfigurationAWS Health Checks

Challenges

Session InconsistencyShopping Cart ResetsIncomplete Transactions

Solutions

Sticky SessionsSession ConsistencyHigh Availability

Key Results

Restored consistent user sessions with no cart resets

session consistency

Increased cart completion rates during promotional campaigns

conversion improvement

No application code changes required

application changes

Seamless failover during instance failures

failover handling

Enhancing Session Consistency with Sticky Sessions in AWS ALB

AMJ Cloud Technologies partnered with a mid-sized online retail platform to address session inconsistency issues and improve user experience. This case study demonstrates how enabling sticky sessions on AWS Application Load Balancer (ALB) restored session continuity, boosted conversion rates, and maintained high availability.

Situation

The client, an e-commerce platform serving thousands of concurrent users, hosted their application on AWS using an Application Load Balancer (ALB) and EC2 instances across two Availability Zones (AZs). During peak traffic periods, such as flash sales and promotional events, users reported intermittent shopping cart resets and unexpected logouts. These issues stemmed from the ALB’s default behavior of routing user requests to different backend instances, causing session state loss since session data was stored locally on each instance.

Task

Our team was tasked with designing a solution to meet the following objectives:

  • Ensure consistent user sessions without losing shopping cart data.
  • Improve cart completion rates and reduce abandoned carts during high-traffic periods.
  • Maintain the existing application architecture without requiring a full refactor to distributed session storage (e.g., Redis or DynamoDB).
  • Preserve high availability and fault tolerance across AZs.
  • Implement changes with minimal disruption to operations.

The project was executed by a team of cloud architects and DevOps engineers over a three-week timeline.

Action

To achieve these objectives, we implemented duration-based sticky sessions on the client’s AWS Application Load Balancer and validated the setup for performance and resilience:

  1. Sticky Session Activation:

    • Enabled duration-based sticky sessions at the target group level using the ALB’s native cookie-based method (AWSALB).
    • Retained the default session duration of 7 days to ensure session continuity throughout user interactions.
  2. Cross-Zone Load Balancing Compatibility:

    • Ensured Cross-Zone Load Balancing remained enabled to support even traffic distribution and fault tolerance while respecting session affinity.
    • Validated that sticky sessions worked seamlessly across AZs without compromising load distribution.
  3. Health Checks & Failover Logic:

    • Fine-tuned AWS Health Checks to quickly detect instance failures.
    • Configured the ALB to automatically reroute users to healthy instances and issue new session cookies if a sticky session target became unhealthy.
  4. CORS Considerations:

    • Addressed cross-origin issues by verifying the use of the AWSALBCORS cookie for frontend applications operating across multiple domains (e.g., subdomains for international stores).
    • Ensured proper CORS headers were set to maintain stickiness across origins.
  5. Testing and Validation:

    • Conducted simulated traffic tests to confirm session consistency during peak loads.
    • Monitored cart completion rates and session behavior to validate improvements.

The team collaborated with the client to monitor metrics during rollout and fine-tuned configurations to optimize performance.

Result

The sticky sessions implementation delivered significant outcomes:

  • Restored Consistent User Sessions with No Cart Resets: Users remained connected to the same backend server, ensuring shopping carts remained intact.
  • Increased Cart Completion Rates During Promotional Campaigns: Improved user experience led to higher conversion rates, especially during high-traffic events.
  • No Application Code Changes Required: The ALB-managed cookie solution minimized engineering effort and avoided the need for third-party session storage.
  • Seamless Failover During Instance Failures: The ALB automatically redirected users to healthy instances, preserving a seamless experience during failures.
  • Operational Simplicity: Quick implementation with minimal disruption.

This solution has become a reference for AMJ Cloud Technologies’ session management projects, showcasing our expertise in AWS load balancing and user experience optimization.

Technologies Used

  • AWS Application Load Balancer (ALB): Managed incoming traffic.
  • Duration-Based Sticky Sessions (AWSALB Cookie): Ensured session affinity.
  • Cross-Zone Load Balancing: Supported even traffic distribution.
  • EC2 Auto Scaling: Scaled instances dynamically.
  • CORS Configuration: Enabled cross-origin session consistency.
  • AWS Health Checks: Monitored instance health.

Key Use Cases

This architecture is suitable for:

  • E-commerce platforms with stateful session requirements.
  • Web applications needing consistent user sessions without distributed storage.
  • Enterprises seeking low-effort, high-impact solutions for session management.

Ready to enhance your session consistency? Contact us to explore how AMJ Cloud Technologies can help.

Key Takeaways

This case study highlights the impact of AWS ALB sticky sessions in ensuring session continuity and improving user experience. By leveraging a simple yet effective feature, we restored session consistency, boosted conversion rates, and maintained high availability for an e-commerce client. AMJ Cloud Technologies is dedicated to delivering practical cloud solutions for scalable and user-friendly architectures.

Architectural Diagram

Need a Similar Solution?

I can help you design and implement similar cloud infrastructure and DevOps solutions for your organization.