When durability and read throughput pull in opposite directions, unify POS sales, ERP stock, supplier lead times, and weather/promo signals in an Iceberg Feature Lakehouse feeding distributed Spark/Ray TFT training and a global MILP optimizer.
TL;DR30-second simplified summary▾
To finish 50M series inside a 4-hour nightly SLA, stream Arrow batches to Ray GPU TFT workers, reconcile with diagonal WLS MinT per category, and solve MILP per DC-vendor.
50M Series Scale & Daily Batch Window.
Why this matters: Size compute, storage, and SLA windows for 50M SKU-Store time series.
Think of 50M Series Scale & Daily Batch Window as the intuition layer for Design a Supply Chain Inventory & Demand Forecasting System: Size compute, storage, and SLA windows for 50M SKU-Store time series.
50M SKU-Store combinations x 730 days of history = 36.5B daily feature rows (~4 TB Zstd Parquet in Iceberg). The nightly forecast + MILP optimization must complete within a 4-hour batch window (00:00–04:00 UTC) so ERP Purchase Orders are ready before 05:00 warehouse shifts.
50M Series & 4-Hour Nightly Replenishment Window
1.Global Model vs Per-SKU: A single global TFT model learns cross-SKU promo patterns, avoiding 50M tiny models.
2.1-Hour Buffer: Targeting 3h completion inside a 4h SLA leaves room for MILP retries.
Global Temporal Fusion Transformers on Spark/Ray score 50M series inside a strict 4-hour nightly SLA.
Lakehouse Ingestion & Multi-Signal Architecture.
Why this matters: Unify streaming POS/ERP events with external promo and weather data.
Think of Lakehouse Ingestion & Multi-Signal Architecture as the intuition layer for Design a Supply Chain Inventory & Demand Forecasting System: Unify streaming POS/ERP events with external promo and weather data.
POS checkouts and ERP inventory adjustments stream via Kafka into Apache Iceberg for real-time stockout alerting, while supplier lead-time logs and weather/promo calendars join nightly in the Feature Store before distributed TFT inference.
Kafka + Iceberg Feature Lakehouse Pipeline
1.ACID Time-Travel: Iceberg snapshots allow exact reproduction of last Tuesday's forecast inputs.
2.Exogenous Signals: Future-known promo calendars and 14-day weather forecasts boost TFT accuracy.
An Iceberg Feature Lakehouse unifies real-time POS/ERP state with batch promo and weather calendars.
- Problem
- How to implement Design a Supply Chain Inventory & Demand Forecasting System without hitting unbounded tail latency, state divergence, or operational fragility.
- Naive Solution
- Use a single unpartitioned path with unbounded retries and synchronous global coordination.
- Why It Fails
- Global coordination serializes throughput under load, while unbounded retries amplify transient stalls into full outages.
- Alternatives
- Compare synchronous strict-consistency paths against bounded asynchronous replication, local caching, or partitioned ownership.
- Engineering Decision
- When durability and read throughput pull in opposite directions, unify POS sales, ERP stock, supplier lead times, and weather/promo signals in an Iceberg Feature Lakehouse feeding distributed Spark/Ray TFT training and a global MILP optimizer.
- Trade-Offs
- Gains predictable p99 latency and fault isolation in exchange for explicit bounding, observability, and slightly higher implementation complexity.
When Design a Supply Chain Inventory & Demand Forecasting System experiences a sudden 5x traffic spike alongside a slow downstream dependency, which engineering choice best protects system stability?
Distributed Ray/Spark TFT Quantile Inference.
Why this matters: Scale Temporal Fusion Transformer inference across 50M series using GPU workers.
Training 50M separate ARIMA models fails on sparse SKUs and takes too long.
A global Temporal Fusion Transformer (TFT) trained across all SKUs shares seasonal and promotional representations.
Category-Sharded Ray GPU TFT Inference
1.Quantile Crossing Fix: Sort or clamp (P10, P50, P90) outputs so P90 never dips below P50.
2.Cold-Start SKUs: Global TFT uses static item metadata (category, price) to forecast brand-new SKUs.
Streaming Arrow batches into a global TFT on Ray GPUs scores 50M series in ~90 minutes.
Parallel Category-Scoped MinT Reconciliation.
Why this matters: Reconcile 50M forecasts without inverting a 50M x 50M matrix.
Think of Parallel Category-Scoped MinT Reconciliation as the intuition layer for Design a Supply Chain Inventory & Demand Forecasting System: Reconcile 50M forecasts without inverting a 50M x 50M matrix.
A single global MinT matrix over 50M nodes is intractable. Because product categories (e.g., Dairy, Electronics) have disjoint replenishment hierarchies, we partition reconciliation by Category x Country, reducing each MinT solve to ~50K nodes that finish in seconds per Spark executor.
Category-Partitioned Diagonal WLS MinT
1.Non-Negativity Clip: MinT projections can occasionally produce tiny negative values; clip >= 0 and re-balance.
2.O(N) Scaling: Using diagonal WLS covariance makes 50M-node reconciliation fast and memory-safe.
Partitioning by disjoint product categories and using diagonal WLS makes MinT scale linearly.
Decomposed MILP Purchase Order Optimization.
Why this matters: Generate constrained Purchase Orders and Transfer Orders within 30 minutes.
Think of Decomposed MILP Purchase Order Optimization as the intuition layer for Design a Supply Chain Inventory & Demand Forecasting System: Generate constrained Purchase Orders and Transfer Orders within 30 minutes.
Solving one MILP with 50M integer variables would time out. We decompose by Regional DC + Supplier Vendor group, optimizing multi-SKU truckloads, MOQ rounding, and DC cubic capacity in parallel across Spark workers using HiGHS.
Vendor-Decomposed MILP Replenishment
1.Idempotent PO Keys: Key every PO by (plan_date, dc_id, vendor_id) so retries never double-order.
2.Case-Pack Rounding: Suppliers ship in full cases/pallets; MILP models exact discrete pack multiples.
Decomposing MILP by DC and vendor solves truckload and capacity constraints in parallel.
Real-Time Intraday Stockout & Disruption Alerts.
Why this matters: React to sudden viral spikes or port delays without waiting for the nightly batch.
Think of Real-Time Intraday Stockout & Disruption Alerts as the intuition layer for Design a Supply Chain Inventory & Demand Forecasting System: React to sudden viral spikes or port delays without waiting for the nightly batch.
While POs run nightly, a viral social-media mention can wipe out regional stock by noon. A Flink streaming job monitors live Kafka POS velocity against remaining DC safety stock, firing intraday emergency Transfer Orders and Stockout Alerts within 60 seconds.
Flink Intraday Burn-Rate & Emergency Transfer
1.60-Second Detection: Intraday Flink alerts catch viral sell-outs 12 hours before nightly batch runs.
2.Cross-DC Rebalance: Re-routing surplus stock from neighboring DCs avoids expedited air-freight.
Streaming Flink burn-rate checks catch intraday viral spikes long before the nightly batch.
Forecast Value Added (FVA) & Human Override Tracking.
Why this matters: Measure whether planner manual overrides actually improve or hurt forecast accuracy.
Think of Forecast Value Added (FVA) & Human Override Tracking as the intuition layer for Design a Supply Chain Inventory & Demand Forecasting System: Measure whether planner manual overrides actually improve or hurt forecast accuracy.
Supply chain planners often manually override ML forecasts. Logging both the raw TFT/MinT output and the final overridden number in Iceberg enables Forecast Value Added (FVA) tracking—automatically flagging planners or SKUs where overrides consistently worsen WAPE/Bias.
ML Baseline vs. Planner Override FVA Loop
1.Reason Codes: Requiring reason codes (e.g., 'local event') turns overrides into new model features.
2.Bias Audit: FVA eliminates optimism/pessimism bias in manual planner adjustments.
Forecast Value Added auditing measures whether human overrides improve or degrade WAPE.
Practice: Make the trade-off yourself.
How do you make MinT hierarchical reconciliation and MILP optimization tractable for 50M SKU-Store series within a 4-hour nightly window?