Design an E-Commerce Platform like Amazon
Understanding the Problem
🛍️ What is an e-commerce platform? An e-commerce platform lets people find products, put them in a cart and pay for them online, while the business tracks stock and ships the orders. Amazon, Walmart.com and Target.com are the familiar examples. Behind the storefront there are a few very different systems glued together: a huge, read-heavy catalog, a search engine, per-user carts and a correctness-critical checkout.
The question is broad on purpose. Your interviewer wants to see whether you can split a big product into parts with very different requirements, give each part the right storage and consistency model, and then go deep on the one or two places where things get hard.
Functional Requirements
Start by agreeing on scope. A real marketplace includes sellers, recommendations, reviews, ads, warehouses and returns. We'll focus on the shopper's journey from finding a product to paying for it.
Core Requirements
- Users should be able to view product pages: details, images, price and whether it's in stock.
- Users should be able to search for products by keyword and narrow results with filters (category, brand, price range, rating), with counts next to each filter value.
- Users should be able to add items to a cart, change quantities and come back to it later, on any device.
- Users should be able to check out: place an order for the items in their cart and pay for it.
Below the line (out of scope)
- Seller onboarding and listing tools.
- Recommendations, reviews and ads.
- Warehouse operations, shipping and returns (see inventory management for the stock side).
- Coupons and promotions beyond a simple discount line (see coupon system).
Non-Functional Requirements
Ask your interviewer about scale and about the sale days, because those set the design. We'll assume 100M daily active users, a catalog of 500M products, and a few sale days a year (think Prime Day or Singles' Day) where traffic runs 5 to 10 times a normal peak and the platform does several billion dollars of sales in a day.
Core Requirements
- The system should serve product pages and search results fast: under 200 ms at p99 for the API, at peak.
- The system should never sell stock it doesn't have, and never charge a customer twice for one order. Checkout needs strong consistency; browsing does not.
- Carts should be durable. An item added on a phone should still be there on a laptop next week.
- The system should be highly available, especially checkout. Every minute of downtime on a sale day is lost revenue that doesn't come back.
- The system should absorb sale-day spikes without falling over, degrading the nice-to-have features before the essential ones.
Below the line (out of scope)
- Multi-region active-active checkout. We'll keep orders in one home region per user.
- PCI compliance details beyond "card data never touches our servers; the payment provider tokenizes it."
Now the numbers, because they make the main point of the design.
- Product views. 100M users × 30 page views a day = 3B views a day, about 35k per second on average and around 100k/s at the daily peak. On a sale day, plan for ~500k/s.
- Searches. 100M × 5 = 500M a day, about 6k/s on average, with sale-day peaks on the order of 50k/s.
- Orders. A normal day is ~10M orders, about 115/s. A sale day might bring 100M orders, ~1,150/s on average, with spikes on the order of 10k orders/s when headline deals open. At ~3 items per order that's 30k inventory reservations per second.
- Catalog size. 500M products × ~5 KB of metadata = 2.5 TB, plus images in object storage.
Reads outnumber orders by roughly 50 to 1 at peak and more on a normal day. And the two sides want opposite things: browsing is happy with data that's a few seconds stale but needs huge read throughput, while checkout is small in volume but has to be exactly right.
The most useful sentence you can say early in this interview is "browsing and buying are different systems." Catalog and search can be eventually consistent and cached to death. Inventory, orders and payments get transactions and idempotency. Most weak answers try to give the whole platform one consistency model.