Design Amazon Warehouse Fulfillment System
Problem Statement
Design the order fulfillment system that routes orders from placement to shipment. The system must track inventory in real time across thousands of warehouses and assign orders to the optimal fulfillment center.
Requirements Clarification
Functional:
- Accept incoming orders and assign to fulfillment centers
- Track inventory levels per SKU per warehouse in real time
- Optimize assignment by distance, inventory availability, and SLA (Prime 1-day vs standard)
- Update order status through picking, packing, and shipping stages
Non-Functional:
- 10M orders/day โ ~115 orders/second
- Inventory reads must reflect stock within 1 second of change
- No overselling (strong consistency required for inventory decrement)
- System must handle warehouse outages gracefully
Critical Design Decision: Inventory Consistency
Inventory decrement is the most dangerous operation. Two approaches:
Optimistic Locking
Read stock level, attempt decrement with version check. Retry on conflict. Works for low contention SKUs.
Reserve-Then-Confirm
Reserve inventory (soft lock) at order placement. Confirm (hard decrement) only when payment clears. Releases reservation if payment fails after TTL.
Key Concepts to Master
A distributed system can only guarantee two of three: Consistency, Availability, and Partition Tolerance.
Horizontal partitioning of a database across multiple machines to distribute load beyond a single server's capacity.
Asynchronous communication buffer between services. Decouples producers from consumers and provides durability during traffic spikes.
Further Reading
Resources that cover this problem in depth.