Design an Inventory Management Service
Design an authoritative inventory service that supports safe point adjustments and large asynchronous file-based updates.
Problem statement
For this exercise, assume an inventory platform is the system of record for on-hand quantity at each product-location pair. Internal clients read inventory and submit single quantity adjustments, while operators submit large batch corrections by uploading a delimited file to S3 and tracking its processing.
Each point adjustment has a client-generated idempotency key and an expected inventory version; each file row has a stable row ID, signed quantity delta, and expected version.
An acknowledged adjustment must never affect inventory twice, concurrent writers must not silently overwrite one another, and every applied change must be auditable. A bulk job may complete partially: invalid or conflicting rows appear in a downloadable result report without rolling back unrelated successful rows.
Pricing, order placement, reservations, procurement, warehouse routing, and collection of physical counts are outside the first version.
What to build
- Clients can read the current on-hand quantity and version for a product at a location.
- Clients can apply an idempotent signed quantity adjustment with an expected version and receive the resulting quantity and version or a conflict.
- Operators can create a bulk job, upload its file to S3, finalize the upload, and inspect job progress.
- The platform validates and applies bulk rows independently, supports safe retries, and produces a durable per-row success or error report.
At scale
- Assume 20 million product-location inventory records, with peaks of 50,000 reads and 10,000 point adjustments per second.
- Assume a bulk file can contain up to 5 million rows and several large jobs may run concurrently, so upload and processing are asynchronous.
- Target a 200 ms p95 inventory read and a 500 ms p95 acknowledgment for a healthy point adjustment; bulk jobs may take hours but must expose progress.
- Every acknowledged adjustment must be durable and auditable for one year, while queues and workers may deliver bulk work more than once.