Lesson 3 of 16
42. Design E-commerce Cart and Checkout (Amazon / Flipkart)

42.2 How big is this, really?

3 min read+10 XP

Step 2: Estimates (5 minutes)

Assume about 2 KB per cart, at least 3 writes per order (order, items, reservation), and a 10-minute reservation hold.

WhatWorkingResult
Cart storage50 million × 2 KB≈ 100 GB: fits a sharded key-value store
Peak order writes5,000 orders/s × 3≥ 15,000 writes a second at sale opening
Hot itemsa sale phone with 100,000 units, bought at thousands a secondone stock row under huge contention (Chapter 43)
Payment calls5,000 a second to external gatewaysgateways' own limits matter (Chapter 25)

What the numbers say, out loud:

  • "Carts are big in count but simple: a key-value store sharded by user."
  • "Orders need transactions: shard the orders database by order or user ID, with replicas."
  • "Stock is the hot spot: one popular product means many writes to one row. Conditional updates, splitting stock across warehouses or buckets, and a queue at the front for flash sales (Chapter 43)."

Interviewer pushback:

  • "Why not keep the cart in the browser only?" → Guest carts can start there, but signed-in users expect the cart on every device, and abandoned-cart reminders need it server-side. Merge at login (42.6).

Memory code: "Carts are many and simple; orders are fewer and strict; stock is the hot row."