Building a Scalable and Resilient E-Commerce Application: MyClothes.com

In this section, we transition from a stateless web application (WhatIsTheTime.com) to a stateful e-commerce platform (MyClothes.com). This introduces new challenges, such as maintaining user sessions, ensuring high availability, and scaling efficiently.

Challenges in a Stateful Web Application

MyClothes.com needs to handle:

Hundreds of concurrent users navigating and adding items to a shopping cart.

Session persistence to prevent users from losing their cart when requests are routed to different servers.

Horizontal scalability, ensuring the web application remains stateless wherever possible.

Secure and efficient data storage, including user details and shopping cart information.

Initial Architecture & Its Problem

The architecture follows a standard multi-AZ setup:

  1. User requests go through Route 53 (DNS).
  2. Requests are distributed by an ELB (Elastic Load Balancer).
  3. ELB forwards requests to EC2 instances within an Auto Scaling Group.

💥 The issue? Each request may hit a different EC2 instance, causing users to lose their shopping cart as there’s no centralized session management.


Solving the Shopping Cart Problem

Solution 1: ELB Stickiness (Session Affinity)

Solution 2: Web Cookies (Client-Side Storage)