Distributed Systems for Backend Engineers · Capstone
Capstone: Multi-Region Inventory
Design inventory for a retailer selling in three regions.
Scenario
A retailer sells from warehouses in the US, EU and APAC. Product pages must load fast everywhere; overselling limited items (sneaker drops) is unacceptable; regular items can tolerate small oversell risk with backorders. A region outage must not stop sales in other regions.
Requirements
- Fast reads globally
- No oversell for limited items
- Regional failure isolation
- Accurate stock reporting
Constraints
- Cross-region latency ≈ 100–200 ms
- Drops: 50k users, 1k items, 2 minutes
Deliverables
- Choose consistency per operation and the data architecture.
- Explain failure behavior and reconciliation.
Draft each deliverable below before revealing the model answer and rubric.
Further reading: Designing Data-Intensive Applications
Deliverables
Choose consistency per operation and the data architecture.
Model answer
Stock is owned per warehouse region (home region per SKU-warehouse); reads served from local replicas/caches (eventual, fine for display). Regular items: reserve locally in the warehouse's region with conditional decrements; small oversell handled by backorders. Limited drops: route reservations to a single strongly consistent authority (one region or a distributed SQL table with serializable transactions) — users accept extra latency; virtual waiting room in front.
Rubric
Strong answers choose different consistency levels per operation and give limited items a single source of truth.
Explain failure behavior and reconciliation.
Model answer
Region outage: other regions keep selling their own warehouse stock; SKUs homed in the failed region show 'limited availability' (no cross-region writes without the owner) or fail over to a standby with RPO bounds. Events via outbox/CDC feed a global reporting view; nightly reconciliation compares warehouse counts with reservations; fencing tokens/leases if ownership moves between regions.
Rubric
Look for explicit partition-time behavior (CAP choice) and reconciliation.
Open in the app to mark lessons complete, take notes and track your progress.