Design an e-commerce marketplace similar to eBay where buyers browse a large product catalog, compare offers from multiple sellers, manage shopping carts, place orders, and complete checkout with payment processing. The platform must handle the full purchase lifecycle from product discovery through order fulfillment.
The system serves millions of daily active users generating heavy read traffic on product listings and search, with periodic write bursts during promotions and flash sales. Inventory is scarce for popular items, making race conditions a real concern when multiple buyers attempt to purchase the last available unit simultaneously. Your design must ensure that no item is oversold, payments are processed exactly once, and the checkout flow degrades gracefully when downstream services experience issues. Consider how you would separate read-heavy catalog browsing from write-heavy transactional operations.
Based on real interview experiences, these are the areas interviewers probe most deeply:
When multiple buyers race for limited stock, overselling erodes trust and creates fulfillment problems. Interviewers expect transactional mechanisms that prevent selling more units than available.
Hints to consider:
Search traffic vastly exceeds transaction volume, and complex filtering queries would overwhelm a transactional database. Interviewers look for separation of concerns between OLTP and search infrastructure.
Hints to consider:
Checkout spans multiple services (tax calculation, shipping estimation, payment authorization, order creation) and must handle partial failures without double-charging or orphaned inventory holds.
Hints to consider:
Carts must survive browser closes, app switches, and device changes. Interviewers probe how you store cart state efficiently and handle stale pricing or out-of-stock items.
Hints to consider:
Confirm whether you are designing a single-seller storefront or a multi-seller marketplace, as this affects catalog management and checkout flows. Ask about expected traffic (searches per second, orders per second) and product catalog size. Clarify payment methods and currency support. Verify if flash sales or promotional events with extreme traffic spikes are in scope. Establish whether real-time recommendations and personalization are required.
Sketch service-oriented components: Product Catalog Service (manages listings, images, and seller information in a relational database), Search Service (backed by Elasticsearch for queries and faceted filtering), Cart Service (Redis-backed with durability fallback), Inventory Service (authoritative source of available quantities with transactional guarantees in PostgreSQL), Checkout Orchestrator (coordinates the saga across inventory, payment, tax, and order services), Payment Service (wraps provider APIs with idempotency and retry logic), Order Service (manages order lifecycle and shipment tracking). Place a CDN for static assets and product images, and use Kafka to propagate inventory changes to the search index asynchronously.
Walk through a purchase flow. The user clicks "Buy Now" and the Checkout Orchestrator starts a database transaction against the Inventory Service. It queries available quantity with a row-level lock (SELECT available_count FROM inventory WHERE product_id = ? AND variant_id = ? FOR UPDATE), decrements the count, and inserts a reservation with a 10-minute expiration and PENDING status. The orchestrator then calls the Payment Service with an idempotency key derived from order ID. On payment authorization, the reservation transitions to CONFIRMED and a row is inserted into the Orders table. If payment fails, the transaction rolls back and inventory is released. A background job scans for expired reservations every 30 seconds and releases them. Discuss how the row-level lock prevents two concurrent transactions from overselling, and how indexing on (product_id, variant_id) keeps the lock scope narrow.
Cover read scalability: product browse and search queries hit Elasticsearch and Redis caches, never the transactional inventory database. Inventory changes publish events to Kafka that update the Elasticsearch index with eventual consistency. Discuss monitoring: track checkout success rates, reservation timeout rates, payment failure rates, and search latency percentiles. Address multi-region considerations: read replicas near users for catalog queries with all inventory writes routed to a primary region. Explain fraud detection by scoring transactions against behavioral patterns and flagging anomalies. Touch on observability needs including distributed tracing across the checkout saga to diagnose slow steps.