PLAYBOOK #06AWS Verbatim & System Design•15 min read
Amazon System Design Interview Scenarios & Answers
End-to-end architectural solutions, Mermaid diagrams, and verbatim interview defense scripts for Amazon Prime Day flash sales, distributed order sagas, and real-time tracking.
Prime Day Flash SaleSaga PatternRedis LuaDynamoDB Global Tables
The Bar Raiser Standard: In an Amazon System Design interview, the interviewer does not just grade whether your diagram works. They evaluate your ability to think like an Owner and an Architect—anticipating edge-case failures, preventing cascading collapses, and proactively articulating the trade-offs of your choices.
🏛️ Scenario 1: Design Amazon Prime Day Flash Sale (Extreme Concurrency & Hotspots)
A. The Challenge
- Requirement: 500,000 users attempt to purchase a limited inventory item (1,000 units of a discounted Sony TV) at 12:00:00 PM.
- Failure Modes:
- Traditional relational databases crash due to row-level lock contention (
SELECT ... FOR UPDATEonstock_count). - Single partition key bottleneck in NoSQL (
PK = "ITEM#123"throttles at 1,000 WCU). - Thundering herd overwhelms the payment gateway.
- Traditional relational databases crash due to row-level lock contention (
B. Architecture Solution
Synthesizing vector architecture diagram...
C. The Distributed Techniques
- Virtual Waiting Room & Rate Limiting:
- CloudFront serves a static HTML/JS waiting room hosted in S3.
- AWS WAF enforces rate limits (e.g., max 5 requests/10s per IP) to block automated scalper bots.
- Atomic Inventory Reservation in Memory (Redis + Lua):
- Do NOT write to the database synchronously on the request path!
- An in-memory ElastiCache Redis cluster evaluates an atomic Lua script:
lua
local stock = tonumber(redis.call('get', KEYS[1])) if stock > 0 then redis.call('decr', KEYS[1]) return 1 -- Success else return 0 -- Sold out end - Lua executes atomically in a single Redis thread, reserving stock in with zero lock contention.
- Write Sharding the Database Counter:
- If updating DynamoDB directly, a single item (
stock_count) caps at 1,000 writes/sec. - Write-Sharding Pattern: Split the 1,000 stock into 10 distinct items:
ITEM#123_SHARD_0toITEM#123_SHARD_9(each holding 100 stock). A randomized hash directs requests across the 10 shards, multiplying throughput by (10,000 writes/sec).
- If updating DynamoDB directly, a single item (
- Asynchronous Order Processing (SQS FIFO):
- Users who successfully reserve a stock token receive
202 Acceptedwith a temporary reservation valid for 10 minutes. - The actual order placement and credit card charge execute asynchronously via SQS FIFO to protect the payment gateway from sudden traffic spikes.
- Users who successfully reserve a stock token receive
D. The 3-Axis Trade-off Defense
Synthesizing vector architecture diagram...
- Performance Defense: "We moved the critical inventory deduction path to an in-memory Redis cluster running an atomic Lua script. This eliminates disk I/O and row-level locking bottlenecks, delivering P99 latency under 3ms."
- Cost Defense: "Because the flash sale only lasts 2 hours, we provision a high-memory ElastiCache cluster for the peak window and scale it down immediately after, avoiding long-term provisioned database costs."
- Maintainability & Reliability Trade-off (Concession): "The trade-off is eventual consistency between Redis and the authoritative database. If a Redis node crashes before flushing state, there is a risk of inventory discrepancy. We mitigate this by enabling Redis Multi-AZ with automated failover and running an asynchronous reconciliation worker that reconciles Redis reservations against DynamoDB completed orders."
🏛️ Scenario 2: Design Distributed Order Fulfillment Pipeline (Saga Pattern & Idempotency)
A. The Challenge
- Requirement: Complete an order involving Order Creation, Payment Charging, Warehouse Inventory Allocation, and Notification dispatch across independent microservices.
- Failure Modes:
- Two-Phase Commit (2PC) locks database tables across services, causing latency cascading and catastrophic deadlocks.
- Network timeout during payment: did the payment succeed or fail?
B. Architecture Solution
Synthesizing vector architecture diagram...
C. The Distributed Techniques
- Orchestrated Saga with AWS Step Functions:
- Avoid distributed database transactions (2PC). Each microservice executes its own local transaction in its own database.
- AWS Step Functions orchestrates the sequence. If Step 3 (Payment) fails, Step Functions executes Compensating Transactions in reverse order (e.g.,
ReleaseInventoryandCancelOrder).
- Idempotency Token at Every Boundary:
- Every request carries an
Idempotency-Key: <UUID>generated by the client. - The Payment Service stores processed keys in DynamoDB with a conditional write:
attribute_not_exists(IdempotencyKey). - If a timeout occurs and the client retries, the Payment Service detects the existing key and returns the previously processed transaction status without double-charging.
- Every request carries an
D. The 3-Axis Trade-off Defense
- Maintainability Defense: "We chose an Orchestrated Saga via AWS Step Functions over a Choreographed (event-driven) Saga. In an e-commerce fulfillment pipeline with complex compensation paths, choreography leads to 'spaghetti event flows' where understanding system state requires distributed tracing across 10 event queues. Step Functions visualizes the entire execution DAG, providing centralized error handling and observable state."
- Performance Trade-off: "Orchestration introduces a centralized coordinator, adding ~20-50ms overhead per step compared to direct asynchronous messaging. For an order fulfillment workflow spanning several seconds, this latency is imperceptible to the user."
- Cost Defense: "Step Functions Express Workflows cost $1.00 per million executions, making it extremely cost-effective compared to maintaining custom workflow orchestration engines on EC2."
🏛️ Scenario 3: Design Global Distributed Key-Value Store (DynamoDB Internals)
A. The Challenge
- Requirement: Provide a global, multi-tenant distributed key-value store supporting millions of QPS with latency and tunable consistency.
B. Architecture Solution
Synthesizing vector architecture diagram...
C. The Distributed Techniques
- Consistent Hashing with Virtual Nodes:
- Partition keys are hashed using MD5/SHA-256 onto a 128-bit circular ring.
- Each physical storage node is mapped to 200 virtual nodes (Vnodes) on the ring to guarantee uniform data distribution and avoid "hot fingers."
- Sloppy Quorum & Hinted Handoff:
- If a primary replica node is down during a write, the write is accepted by an alternate healthy node with a "hint" in its metadata indicating the intended destination.
- When the primary node recovers, the alternate node delivers the hinted data back (Hinted Handoff), maximizing write availability.
- Tunable Quorums ():
- With replication factor :
- Read Quorum , Write Quorum .
- Since , the read set and write set always overlap by at least one node, guaranteeing strong consistency.
- If the client chooses and , the system operates as high-availability eventual consistency ().
- With replication factor :
⏱️ The 45-Minute Amazon Interview Execution Blueprint
| Time Window | Phase | Interviewer Expectation | What to Say / Draw |
|---|---|---|---|
| 00:00 – 05:00 | 1. Scope & Clarify Requirements | Demonstrates Customer Obsession & Think Big. Never jump straight to drawing! | • Functional Requirements (Top 3 core use cases). • Non-Functional Requirements: Latency (P99 < 100ms), Availability (99.99%), Scale (RPS, Storage volume). • Out-of-scope boundaries. |
| 05:00 – 10:00 | 2. Back-of-the-Envelope Math | Quantitative estimation of throughput, storage, and network bandwidth. | • Read RPS vs. Write RPS. • Storage per day / year: . • Bandwidth: . |
| 10:00 – 25:00 | 3. High-Level Design & Core Flows | End-to-end architecture diagram showing data and control paths. | • Edge (CDN / Route 53 / API Gateway). • Compute tier (Stateless microservices / Lambda). • Primary Data Store (DynamoDB single-table schema or Aurora). • Caching & Asynchronous queues. |
| 25:00 – 35:00 | 4. Deep Dive & Failure Modes | Where Senior SDEs (L6) win the interview. Anticipate failures before being asked! | • Hot partition mitigation (Salted keys / write sharding). • Circuit breakers & Exponential backoff with full jitter. • End-to-end Idempotency keys. • Data loss prevention & Disaster Recovery (RPO/RTO). |
| 35:00 – 43:00 | 5. Proactive Trade-Off Defense | Explicitly articulate the 3-Axis Trade-off Matrix. | • Performance vs. Cost vs. Maintainability. • Why you rejected alternative technologies. • What metrics you would monitor to trigger the next architectural evolution. |
| 43:00 – 45:00 | 6. Wrap-up & Q&A | Summarize key architectural guarantees and answer interviewer questions. | Concise recap of SLA compliance, blast radius containment, and operational readiness. |
Part 2: Production Deep-Dive Locked1 Coin = 24 Hours
Unlock Complete Architecture & Production Runbooks
Your Balance:
You have explored the free architectural preview (~39%). Spend 1 Coin to unlock the remaining 3 production deep-dive sections for a full 24 hours.
Sections Included in This 24-Hour Pass:
🏛️ Scenario 2: Design Distributed Order Fulfillment Pipeline (Saga Pattern & Idempotency)
🏛️ Scenario 3: Design Global Distributed Key-Value Store (DynamoDB Internals)
⏱️ The 45-Minute Amazon Interview Execution Blueprint
Connecting to coin treasury...
Keeps page unlocked for exactly 24 hoursSpend coins to fund LLM & compute infrastructure