Design a Multi-Warehouse Shipping Optimizer

Hard45 min
1 / 30
understanding•10 min read

Problem Statement: Fulfillment Decisions Are a Money Problem

Frames the optimizer as a real-time constrained optimization engine sitting between orders, inventory, carriers, and promises.

Problem statement

Design a multi-warehouse shipping optimizer for a national e-commerce retailer. When an order arrives with one or more items, the system must decide which fulfillment node ships which item so that the delivery promise is met at minimum total cost. A fulfillment node can be a regional distribution center, a specialized sort hub, or a retail store shipping from the back room. The decision must factor in current stock position across every node, shipping cost to the destination zone, transit time against the promised date, carrier capacity, node workload, and whether splitting the order across nodes saves money or destroys margin.

This is not a lookup. A naive rule like 'ship from the nearest warehouse with stock' fails in production because the nearest node may be congested, may lack a complementary item (forcing a split anyway), may be past carrier cutoff so the parcel misses the promise date, or may hold the last unit of a fast-moving SKU that a closer customer will pay full price for tomorrow. The optimizer trades these dimensions explicitly and reproducibly.

Why the problem is distinctive

Three properties separate this from generic request routing. First, the decision is constrained by physical reality: inventory counts are ground truth, and every routing decision consumes or releases real stock through reservations. Second, the cost function is combinatorial: a 3-item order across 60 nodes has a large assignment space once splits are allowed, and the marginal cost of adding an item to an existing box differs sharply from opening a new box. Third, the decision is taken under latency pressure at two very different moments: the product page asks 'can you deliver Thursday?' in under 200 ms millions of times a day, while checkout asks for a binding assignment in under 500 ms for each order.

Public evidence shows the category operates at extreme scale. Amazon's 2023 letter to shareholders describes regionalizing its fulfillment network from one national pool into regional networks to reduce the distance packages travel and lower cost to serve, and Amazon was granted the 'anticipatory shipping' patent (US8615473B2) in December 2013 for pre-positioning packages before purchase. Walmart publicly describes using roughly 4,700 U.S. stores as fulfillment nodes, with the frequently cited claim that around 90% of the U.S. population lives within 10 miles of a Walmart location. Target has stated on earnings calls that roughly 95% of its orders are fulfilled through its store network. Shopify acquired Deliverr in May 2022 to build a multi-node fulfillment network advertising two-day coverage, and reported $9.3B in Black Friday Cyber Monday sales across its merchants in 2023. These are cited public figures; they set context, not our design targets.

Design assumptions for this answer

For capacity planning this answer assumes a mature national retailer: 40M DAU, 4M orders/day average, 1.7 items per order, 60 fulfillment nodes, 5 carriers with 6 service levels each, and a 5x peak multiplier for Black Friday-class events. Unless a number is tied to a public company statement above, it is an explicit design assumption, target, or budget.

The four architectural planes

  1. Decision plane: candidate generation, cost model, assignment scoring, split logic, and the fallback rules engine. This is the heart of the interview.
  2. Truth plane: inventory ledger with reservations, rate cards, zone maps, node capability and capacity. Every decision consumes these inputs; the optimizer never guesses them.
  3. Execution plane: order management, warehouse pick release, carrier label purchase, tracking ingestion, and customer notification.
  4. Learning plane: telemetry on cost-to-serve, split rate, promise misses, carrier performance by lane, and the governed ML models that refine transit-time prediction and tie-breaking.

A strong answer keeps these planes separate. The decision plane may degrade to simple rules without losing correctness; the truth plane may never be approximated for binding assignments; the learning plane may never silently change the cost function without a release gate.

Key Highlights

  • •The optimizer decides which node ships which item under inventory, cost, time, and capacity constraints - it is not a nearest-warehouse lookup.
  • •Two latency regimes: sub-200ms availability quotes at browse time versus binding sub-500ms assignment at checkout.
  • •Assumed scale: 40M DAU, 4M orders/day, 1.7 items/order, 60 nodes, 5x event peak - every uncited number is an explicit assumption.
  • •Amazon regionalization, Walmart ship-from-store, Target stores-as-hubs, and Shopify SFN prove multi-node fulfillment is a first-class production discipline.
  • •Four planes: decision, truth, execution, learning - degradation order protects truth before convenience.
Lead With the Economics
State in the first minute that routing is a cost-to-serve decision: every order routed to the wrong node burns margin through extra distance, extra boxes, or a missed promise. This immediately distinguishes a logistics architecture from a generic load balancer.
Do Not Start With 'Nearest Warehouse'
Nearest-in-stock ignores carrier cutoff times, node congestion, split economics, and inventory health. Interviewers use that answer as the baseline you must argue against.

Section Rescue Kit

Buzzwords to use:

Cost-to-ServeFulfillment Node

Safe statements:

  • "I will separate the browse-time availability quote from the checkout-time binding assignment because they have different latency and correctness budgets."
  • "Before picking technologies, let me define the decision inputs: stock, rates, zones, transit times, node capacity, and promise policy."
Design a Multi-Warehouse Shipping Optimizer - System Design | WinJob | WinJob