HLDArena
HLD-330·Transactions & Locking
Hard · 1,500 pts

Real-Time Grocery Batch Picking, Live Substitutions & Dispatch

Design an Instacart-style grocery fulfillment backend coordinating in-store shopper aisle-picking batches, probabilistic shelf stockout updates, 60-second customer live item-substitution approvals, and cold-chain delivery window locking.

Max p99
≤ 65 ms
Availability
≥ 99.6%
Budget
≤ $8,850

Functional Requirements

  • FR-1POST /v1/stores/{store_id}/orders — Reserves delivery-window capacity, snapshots aisle inventory probabilities, and assigns multi-order shopper batch.
  • FR-2POST /v1/orders/{order_id}/substitutions — Pushes real-time out-of-stock replacement proposal to customer and locks payment authorization delta.
  • FR-3PATCH /v1/orders/{order_id}/items/{item_id} — Processes customer approve/refund response or timeout fallback with read-after-write shopper sync.
  • FR-4Must prevent double-claiming shopper batches or delivery-slot overbooking while surviving regional DB brownouts.

Workload Profile

Steady Store Fulfillment50,000 Catalog & Order Sync Read RPS / 9,500 Scan & Sub Write RPS
Sunday Afternoon Grocery Rush138,000 Read RPS / 24,500 Write RPS
Active Working Set38 GB live store-aisle stock probabilities, active orders & delivery-slot counters
Concurrency GateAtomic slot/batch claiming + sub-second shopper <-> customer state sync

Consistency Model

Strict atomic locking on delivery-slot capacity and shopper batch claim; immediate read-after-write on item substitution state.

Relevant practice for

Click an item in Inventory above, or press B to add a component, double-click to name, C to connect.

Design Write-up

Write under ### Architecture for Diagram to take that up directly

Compulsory section · if not written yet, Diagram reads from the start of your write-up.
Architecture: required·FRs mentioned: 0/4·0 boxes · 0 edges
0 words
Hidden Cases #4–#7 run automatically on Submit
Case 1: Smoke & API ContractInput Workload
Read RPS
2,000 rps
Write RPS
400 rps
Key Distribution
Uniform (Low Skew)
Chaos Fault
None (Healthy Cluster)
Expected Pass CriteriaASSERTIONS
• Tail Latency: p99 ≤ 130 ms
• Availability: ≥ 99.6%
Valid end-to-end Client → Compute → Storage topology