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

Three-Sided Food Delivery State Machine & Dasher Offer Lock

Design DoorDash / Uber Eats’ real-time order dispatch coordinator synchronizing customer checkout, kitchen prep state, and exclusive courier offer claims.

Max p99
≤ 105 ms
Availability
≥ 99.4%
Budget
≤ $8,300

Functional Requirements

  • FR-1POST /deliveries/{order_id}/claim — Atomically assigns order_id to exactly one courier within offer TTL.
  • FR-2GET /deliveries/{order_id}/state — Serves live order state machine to diner, merchant tablet, and courier.
  • FR-3DELETE /deliveries/{order_id}/claim — Releases canceled or expired leases/holds atomically and immediately refreshes cached availability.
  • FR-4Two couriers must NEVER simultaneously claim the same order_id even during primary DB failover.

Workload Profile

Afternoon Orders40,000 Status Read RPS / 7,000 State/Claim Write RPS
Friday Dinner Rush108,000 Read RPS / 24,000 Concurrent Claim/State RPS
Active Working Set24 GB in-flight delivery state machines & courier locks
Consistency GateStrict serializable courier assignment + RPO = 0 failover

Consistency Model

Strict serializable CAS on courier claim transitions so two drivers never drive to the same pickup.

Design Write-up
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 ≤ 210 ms
• Availability: ≥ 99.4%
Valid end-to-end Client → Compute → Storage topology