System Design Hard Software Engineer Backend Full Stack

Design an e-commerce flash sale system (handling massive concurrent inventory checkout).

Practise this question with AI feedback

Record your spoken answer or type your response to receive immediate scoring and STAR improvements.

💡 Suggested Approach & Sample Answer

Architecture & Concurrency Control:
- Goal: Sell 10,000 items in 60 seconds with 1,000,000 concurrent buyers, strictly avoiding overselling, database lock contention, or checkout crashes.

1. Ingress & Traffic Smoothing:
- Edge CDN aggressively caches static product pages; API gateway blocks non-authenticated requests and enforces aggressive IP/user rate limiting.
- Virtual Waiting Room: Route excess traffic into an asynchronous queue (RabbitMQ / Redis queue), letting users into the checkout flow in controlled batches.

2. In-Memory Inventory Reservation:
- Never decrement inventory with relational database row locks during a flash sale (causes deadlocks and pool exhaustion).
- Pre-load inventory count into an in-memory Redis cluster. Execute inventory decrement using an atomic Redis Lua script:
if redis.call('get', KEYS[1]) > 0 then return redis.call('decr', KEYS[1]) else return 0 end.
- Successful decrement creates a temporary reservation token with a 10-minute TTL.

3. Asynchronous Order Processing:
- Reserved orders publish to an order creation Kafka topic.
- Background workers process payment collection and write permanent records to PostgreSQL.
- If user abandons or payment fails, token expires and inventory is incremented back into Redis.

🎯 What Interviewers Listen For

How would you answer this in a real interview?

Use our free AI mock practice tool to test your response, analyze speaking pacing, and refine your STAR structure.

🧭 New to system design interviews?

Read the step-by-step system design interview guide: a 45-minute framework, the building blocks interviewers expect, and common mistakes.

🔗 Related System Design Questions