πŸŽ‰ 75% of content is free forever β€” Unlock Premium from $10/mo β†’
CW
Search courses…
πŸ’Ό Servicesℹ️ Aboutβœ‰οΈ ContactView Pricing Plansfrom $10

Design Amazon

System Design ProblemsE-Commerce Systems🟒 Free Lesson

Advertisement

System Design Problems

Design Amazon

Amazon serves 300M+ active users with 350M+ products. This design covers product catalog with search, shopping cart, checkout with inventory management, and order fulfillment.

  • Scale β€” 300M+ users, 350M+ products, 66K orders/hour
  • Availability β€” Must handle Prime Day spikes (10x normal)
  • Inventory β€” Real-time stock tracking across 175+ fulfillment centers

Amazon's core challenge is building a resilient e-commerce platform that handles extreme traffic spikes while maintaining inventory accuracy.

Requirements Clarification

Functional Requirements

  1. Search products with filters and sorting
  2. View product details with reviews
  3. Add to cart and checkout
  4. Order tracking and management
  5. Inventory management
  6. Recommendation engine
  7. Seller marketplace

Non-Functional Requirements

  1. Availability: 99.99% uptime
  2. Latency: Search < 200ms, Checkout < 2s
  3. Consistency: Strong for inventory and payments
  4. Scale: 66K orders/hour, 10x on Prime Day

Amazon's key architectural principle: Design for failure. Every service must degrade gracefully. If the recommendation service is down, the catalog still works. If payment is slow, orders queue rather than fail.

Back-of-the-Envelope Estimation

Order Volume

QPSorder=66K3600β‰ˆ18Β orders/second\text{QPS}_{\text{order}} = \frac{66K}{3600} \approx 18 \text{ orders/second}

Here,

  • 66K66K=Orders per hour
  • 1818=Orders per second

Storage Estimation

Product catalog:

  • 350M products x 10KB metadata = 3.5 TB
  • 350M products x 10 images x 500KB = 1.75 PB (object storage)

Order data:

  • 1B orders/year x 5KB = 5 TB/year

User data:

  • 300M users x 10KB = 3 TB

High-Level Architecture

Amazon ClientsAPI Gateway / CloudFrontCatalog SvcSearch SvcCart SvcCheckout SvcOrder SvcInventory SvcPayment SvcReview SvcEvent Bus (Kafka/SNS)DynamoDB (Cart)Aurora (Orders)ElasticsearchS3 (Images)Redis (Cache)

Inventory Management

DfDistributed Inventory

Amazon tracks inventory across 175+ fulfillment centers. Each product can be stocked in multiple locations. The inventory service uses a reservation system: when a user adds to cart, inventory is temporarily reserved for 15 minutes.

Inventory Reservation

Available=Totalβˆ’Reservedβˆ’Shipped\text{Available} = \text{Total} - \text{Reserved} - \text{Shipped}

Here,

  • TotalTotal=Physical stock in fulfillment center
  • ReservedReserved=In carts (15-min TTL)
  • ShippedShipped=Already shipped

Inventory accuracy is critical. Amazon uses a combination of: (1) Database reservations with TTL, (2) Idempotent checkout to prevent overselling, (3) Periodic reconciliation audits.

Checkout Flow: The Two-Phase Commit

DfSaga-Based Checkout

Amazon's checkout is a distributed transaction: (1) Reserve inventory, (2) Process payment, (3) Create order, (4) Confirm inventory. If any step fails, compensating transactions undo previous steps.

CartReserve InventoryProcess PaymentCreate OrderConfirmCheckout Saga

Product Search

DfA9 Search Algorithm

Amazon's A9 algorithm ranks products by: (1) Relevance (text match), (2) Popularity (sales velocity), (3) Availability (in-stock), (4) Price competitiveness. The ranking is personalized based on user history.

Search Ranking Score

S=w1β‹…Rrelevance+w2β‹…Rpopularity+w3β‹…Ravailability+w4β‹…RpriceS = w_1 \cdot R_{\text{relevance}} + w_2 \cdot R_{\text{popularity}} + w_3 \cdot R_{\text{availability}} + w_4 \cdot R_{\text{price}}

Here,

  • RrelevanceR_relevance=TF-IDF text match score
  • RpopularityR_popularity=Sales velocity score
  • RavailabilityR_availability=In-stock probability
  • RpriceR_price=Price competitiveness

Data Model

Product Schema

Product=(product_id,title,description,price,category,attributes,images[])\text{Product} = (product\_id, title, description, price, category, attributes, images[])

Here,

  • productidproduct_id=ASIN (Amazon Standard ID)
  • attributesattributes=Key-value product attributes
  • categorycategory=Hierarchical category path

Practice Exercises

  1. Inventory: Design a distributed inventory system that prevents overselling across 175 fulfillment centers.
  2. Cart: How would you handle a user adding an item to cart that goes out of stock before checkout?
  3. Search: Design a search system for 350M products with < 200ms latency.
  4. Prime Day: How would you handle 10x traffic on Prime Day without over-provisioning?

Key Takeaways:

  • Amazon uses service-oriented architecture with graceful degradation
  • Inventory management uses reservation with TTL to prevent overselling
  • Checkout is a saga with compensating transactions for failure
  • A9 search algorithm ranks by relevance, popularity, and availability
  • Design for failure: every service must degrade independently

What to Learn Next

-> Design Dropbox File sync and storage systems.

-> Design Google Search Web-scale indexing and ranking.

-> Saga Pattern Distributed transactions.

-> Idempotency Handling duplicate requests safely.

-> Outbox Pattern Reliable event publishing.

-> Circuit Breaker Preventing cascade failures.

⭐

Premium Content

Design Amazon

Unlock this lesson and 900+ advanced tutorials with a Premium plan.

🎯End-to-end Projects
πŸ’ΌInterview Prep
πŸ“œCertificates
🀝Community Access

Already a member? Log in

Need Expert System Design Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement