HLDArena
HLD-210·Caching & Consistency
Medium · 1,000 pts

E-Commerce Persistent Shopping Cart Backend

Design a low-latency shopping cart service persisting item additions, quantity updates, and promo codes across mobile and web sessions without stale checkout totals.

Max p99
≤ 48 ms
Availability
≥ 99.5%
Budget
≤ $6,100

Functional Requirements

  • FR-1PUT /carts/{user_id}/items — Adds or updates SKU line items and quantities in a shopper cart.
  • FR-2GET /carts/{user_id} — Fetches authoritative item list and subtotal at checkout.
  • FR-3DELETE /carts/{user_id}/items/{sku_id} — Removes line items or clears checked-out carts with immediate cache update/invalidation.
  • FR-4Item additions/removals must immediately appear on subsequent cart reads (read-after-write) and survive DB failover.

Workload Profile

Baseline Shopping34,000 Read RPS / 6,500 Cart Write RPS
Promo Expiry Surge96,000 Read RPS / 22,000 Write RPS
Active Working Set20 GB active shopper carts
Consistency GateRead-after-write accuracy before payment handoff

Consistency Model

Read-after-write consistency required per user_id so checkout never submits stale cached item quantities.

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 ≤ 96 ms
• Availability: ≥ 99.5%
Valid end-to-end Client → Compute → Storage topology