Design a Perishable-Goods Inventory and Location Tracking System
AmazonSoftware Engineer · Technical ScreenLast updated
This question tests the ability to design a distributed inventory system that handles high-frequency location updates and strict FIFO/expiry logic for perishable goods.
Problem Statement
Design a system for a large retail chain to track the inventory and real-time location of perishable goods (e.g., produce, dairy) across multiple warehouses and delivery vehicles.
Functional Requirements
- Track the current location of every inventory item in real-time.
- Record the expiration date of items upon receipt.
- Support querying the nearest N items of a specific product type that expire within a certain timeframe.
- Provide a mechanism to trigger alerts when an item is nearing its expiration date.
Non-Functional Requirements
- High availability for location updates.
- Low latency for inventory lookup queries.
- Data consistency is required for stock counts to prevent over-selling.
- Scalability: The system must handle millions of items and thousands of updates per second.
Expectations
Provide a high-level architecture diagram or description covering:
- API design for reporting locations and querying inventory.
- Data model for items and warehouse locations.
- Database choices for the geo-spatial tracking vs. the inventory state.
- A strategy for handling high-volume location updates without bottlenecking the primary database.
Hints
Hint 1
Consider using a geo-spatial indexing solution like Quadtrees or Geohashing to manage item proximity efficiently.
Hint 2
Think about the difference between a write-heavy ingestion path for sensor data and a read-heavy path for inventory management.
Hint 3
Use a message queue or event streaming platform to decouple location updates from the main database writes.
Follow-up questions
- How would you handle the 'hot spot' problem if a large distribution center receives thousands of item updates simultaneously?
- What specific database technologies would you choose for storing historical location data versus real-time current location data, and why?
- How would you ensure that expired items are automatically purged or flagged if a background service fails?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.