Skip to main content

Building a digital twin discrete event simulation platform for fulfillment optimization

minute read
Des Art H Physical And Twin 3840X2160

By Fulfillment Optimization & Data Science Team

Coupang is reimagining the shopping and delivery experience with the goal of wowing each customer from the instant they open the Coupang app to the moment an order is delivered to their door. At the heart of this promise is our Fulfillment Optimization initiative—delighting customers with lightning-fast delivery while reducing operational costs by dynamically routing billions of orders across hundreds of sites housing tens of millions of inventory units.

Every incoming customer order is analyzed among thousands of possible fulfillment paths in real time, balancing delivery speed, packaging efficiency, and available warehouse and transportation resources. In line with our leadership principles to “Wow the Customer” and “Hate Waste,” our data scientists and engineers continuously develop new operations research models, 3D packaging strategies, and network routing algorithms. However, testing major operational or algorithmic changes directly in live environments carries risk and cannot easily isolate compounding network-wide effects.

To solve this, we built a multi-tenant digital twin Discrete Event Simulation (DES) platform. By mirroring real operations and replaying millions of daily orders at high throughput, the platform allows our global teams to test new network designs, capacity targets, and optimization models virtually before applying them in live environments—unlocking tens of millions of dollars in annual fulfillment cost savings while ensuring smooth, reliable rollouts.

Let’s look at how we designed this simulation platform and what improvements it has enabled so far.

Table of Contents

• Background and challenges

• Why fulfillment requires discrete event simulation

• Designing a three-tier distributed simulation platform

• Order optimization and packaging workflow

• Balancing strict event ordering with high concurrency

• High-density in-memory inventory representation

• Scaling across the ecosystem: Solver and packaging services

• Result of applying the platform

• Future plan

Background and challenges

When a customer places an order on Coupang, our fulfillment optimization system solves a complex multi-commodity flow problem in milliseconds. Fulfilling each order requires making three interconnected decisions simultaneously:

· Fulfillment center sourcing: Selecting which warehouse(s) and internal storage areas should satisfy each customer’s order based on real-time stock availability, geographic proximity, and warehouse workload targets.

· Packaging and split minimization: Determining whether multiple items in an order can be consolidated into a single box or reusable bag—factoring in 3D item dimensions, weight, fragility, and temperature requirements—or if they must be split across multiple shipments.

· Transportation routing: Choosing between direct outbound carrier dispatches and multi-hop inter-warehouse transfer paths so the order meets the customer’s delivery promise at the lowest total cost.

As our global fulfillment network expanded in scale and complexity, teams proposed dozens of new ideas every quarter: new mathematical optimization formulations, smarter multi-item box consolidation rules, dynamic hourly warehouse capacity targets, and new inter-warehouse transfer schedules. We needed a virtual proving ground to answer a fundamental question before deploying to production: How will a proposed change behave across millions of orders, and what will its exact impact be on delivery speed, parcel splits, warehouse utilization, and end-to-end cost?

Why fulfillment requires discrete event simulation

In many e-commerce domains such as search ranking or product recommendations, candidate models can be evaluated offline using stateless historical backtesting, because scoring one customer’s query does not alter the state of the system for the next customer.

Order fulfillment is fundamentally different because every routing decision mutates the physical state of the supply chain:

(1) Sequential inventory depletion: Since the same product may exist in multiple locations in limited quantities, allocating the last local unit of an item to an order placed early in the morning means that unit is no longer available for a subsequent order placed moments later. The second order must be routed to a different warehouse, potentially incurring a shipment split or a longer transit path.

(2) Continuous inbound replenishment: Warehouse inventory is dynamic. Throughout the day, vendor deliveries arrive at fulfillment center docks and associates receive incoming products onto shelves. An item that is out of stock locally at one moment may become locally fulfillable shortly afterward following an inbound replenishment event.

(3) Time-varying dispatch schedules and capacity limits: Delivery trucks depart fulfillment centers on strict outbound dispatch windows, and each center operates under hourly and daily capacity targets. Routing too many multi-item orders to a single cost-efficient warehouse in the morning can exhaust its hourly target by midday, triggering cascading re-routings across the network in the afternoon.

Figure 1. Cascading state dependencies across inventory depletion, inbound replenishment, outbound dispatch schedules, and site capacities

Live A/B testing in production also struggles with these network effects: if control and treatment models share the same physical warehouse inventory, they compete for stock and bias the experiment results. A Discrete Event Simulation (DES) overcomes this by modeling the entire fulfillment network as a chronological stream of discrete events—advancing a virtual clock millisecond by millisecond and maintaining an isolated digital twin of every warehouse, item, and outbound dispatch schedule.

Designing a three-tier distributed simulation platform

Replaying millions of daily orders and tens of millions of inventory units rapidly—so data scientists and engineers can run multiple concurrent experiments every day—required a high-throughput distributed architecture. We designed the platform across three decoupled tiers:

1. Batch data preparation pipeline: Automated daily data pipelines extract production logs and materialize date-partitioned datasets in cloud object storage. This includes initial warehouse inventory snapshots, fulfillment center capacity targets, outbound dispatch schedules, and a unified chronological stream of customer orders merged with warehouse inbound receiving events. Pre-sorting the event stream by timestamp allows the simulator to stream events sequentially without loading an entire day’s orders into memory at once.

2. Simulation orchestrator (Actor-based event engine): The orchestrator is the stateful core of the digital twin. It advances the virtual clock, maintains in-memory warehouse inventory and capacity counters, coordinates the multi-stage optimization workflow for each order through an actor-based framework, and records comprehensive cost and operational metrics for every simulated shipment.

3. Elastic optimization solver and packaging services: The orchestrator delegates mathematical optimization via asynchronous RPC communication to a stateless cluster of operations research solver instances that auto-scale dynamically based on workload demand. It also integrates with our downstream packaging microservices to evaluate 3D box packing and multi-warehouse consolidation options.

Figure 2. Overview of the three-tier digital twin Discrete Event Simulation architecture

Order optimization and packaging workflow

To ensure our virtual digital twin mirrors real operations with high fidelity, each simulated customer order flows through a staged actor pipeline that replicates our production decision process:

(1) Order validation and path filtering: Validates network-wide inventory availability, enriches items with physical dimensions and compatibility attributes, and filters eligible direct and transfer dispatch schedules for the delivery destination.

(2) Candidate path optimization: Invokes the operations research solver service to evaluate candidate fulfillment paths and compute cost-efficient routing assignments.

(3) Single-item fast path: When an order contains only a single unit, it cannot be split across multiple boxes. The orchestrator automatically bypasses the multi-item packaging evaluation stages, significantly reducing processing steps while preserving exact solution quality.

(4) 3D packaging and consolidation evaluation: For multi-item orders, the orchestrator coordinates with the packaging service and solver to evaluate 3D bin packing—selecting optimal box or reusable bag sizes—and explores alternative warehouse and storage area combinations that consolidate items into fewer parcels.

(5) Plan selection and state commit: The combiner actor selects the winning fulfillment plan across all evaluated candidates—balancing on-time delivery promise attainment, parcel consolidation, and end-to-end fulfillment and transportation cost—before immediately decrementing inventory and updating warehouse capacity in the digital twin.

Figure 3. Staged actor workflow for multi-item orders and the single-item fast-path optimization

Balancing strict event ordering with high concurrency

The core systems engineering challenge of discrete event simulation is resolving the trade-off between strict temporal determinism and massive parallelism. Processing orders one by one sequentially preserves exact event ordering, but waiting on remote network calls for every order would make simulating millions of daily orders impractically slow. Conversely, allowing hundreds of threads to mutate shared inventory maps simultaneously with traditional mutex locks creates severe contention on popular items.

We resolved this trade-off through two architectural patterns:

· Segregated concurrency domains: A single deterministic coordinator thread manages the chronological priority queue and applies all state mutations—inventory decrements from orders, inventory additions from inbound receiving, and capacity updates—sequentially via lightweight state-updater commands. Meanwhile, stateless order preparation, asynchronous solver callbacks (using lightweight virtual threads), and packaging service calls execute in parallel across semaphore-guarded actor pools. Because worker threads never mutate shared state directly, our inventory engine requires zero mutex locks.

· Lookahead state prefetching (Prefetch → Cache → Swap): To prevent storage I/O from stalling the coordinator thread when outbound dispatch schedules update or inbound inventory batches arrive, dedicated state actors prefetch upcoming timestamped snapshots in background threads ahead of simulated time. When the virtual clock reaches the update timestamp, the coordinator swaps the in-memory state pointer in sub-millisecond time.

High-density in-memory inventory representation

Maintaining real-time inventory counts for tens of millions of units across hundreds of sites and thousands of internal storage areas using standard object hierarchies would consume tens of gigabytes of memory and trigger frequent garbage collection (GC) pauses during high-rate mutations.

To keep the memory footprint compact and responsive, we designed a packed binary storage layout backed by a contiguous byte buffer and primitive hash maps. Warehouse location identifiers and item stock attributes are packed into compact, fixed-width binary records. When an order is fulfilled or an inbound shipment is received, updating stock is a single in-place integer write at a calculated byte offset—creating zero heap allocations and eliminating garbage collection pauses across millions of inventory updates.

Scaling across the ecosystem: Solver and packaging services

Launching multiple large-scale simulation workloads simultaneously generates significant traffic spikes across our computation tier. Supporting a multi-tenant simulation architecture required co-designing concurrency controls and optimizing dependent services:

1. Adaptive Concurrency Control (AIMD) and priority queuing for the solver cluster: When a simulation starts, our solver cluster scales dynamically from a minimal baseline as demand increases. To prevent cold-start overload and multi-stage pipeline deadlocks (where newly arriving orders consume all solver permits and starve already in-flight orders waiting for downstream refinement), we implemented priority queuing paired with an Additive Increase / Multiplicative Decrease (AIMD) controller. Downstream refinement requests receive higher priority so in-flight orders always drain first, while the AIMD controller smoothly ramps concurrency up as solver instances warm up and automatically backs off if latency or error thresholds are exceeded.

2. Eliminating database bottlenecks in the downstream packaging service: Replaying millions of orders at high concurrency also serves as a powerful diagnostic lens for dependent microservices. When we scaled up concurrent full-day simulations with 3D packaging integration enabled, packaging API latencies became a bottleneck even though CPU utilization on the packaging instances remained low. By adding granular stage-level telemetry, we discovered that each packaging evaluation request was making hundreds of redundant database queries for configuration metadata due to an ineffective legacy cache and uncached missing-key lookups. Replacing it with an in-memory cache featuring negative-lookup caching and hit-rate monitoring eliminated the database bottleneck and enabled multiple simultaneous fast full-day simulations.

Figure 4. (a) Adaptive concurrency ramp-up and priority queuing for the solver cluster; (b) Downstream packaging metadata cache optimization

Result of applying the platform

By turning complex supply chain experimentation into a repeatable, high-speed digital twin workflow—supporting our global fulfillment network and capturing comprehensive cost and operational metrics—our teams have evaluated hundreds of hypotheses across fulfillment, packaging, and transportation. Moving from static rules to dynamic, operations-research-driven routing and validating new strategies on the simulation platform has processed billions of orders in production and delivered tens of millions of dollars in annual fulfillment cost savings.

Experiment Category

What Was Tested in the Digital Twin

Primary Operational Impact

1. Joint Sourcing & 3D Packaging Consolidation

Co-optimizing warehouse storage selection with 3D box allocation and multi-candidate evaluation

More items consolidated per parcel, fewer split shipments, lower packaging material and delivery costs

2. Regional Proximity & Priority Weighting

Refining fulfillment site proximity weighting across single-item and multi-item order profiles

Sourced shipments from sites closer to delivery destinations, reducing transit costs

3. Dynamic Multi-Hop Transfer Routing

Calibrating inter-warehouse transfer paths to consolidate multi-item orders while protecting delivery promises

Lower transportation cost and higher multi-item order consolidation

4. Hourly Capacity Balancing & Inventory Health

Enforcing hourly warehouse workload targets, dynamic balancing, and lifecycle-aware inventory prioritization

Improved adherence to warehouse targets, smoother labor utilization, and reduced inventory waste

Table 1. Key fulfillment optimization pillars validated on the Digital Twin Discrete Event Simulation platform

Key highlights of these improvements include:

· Maximizing parcel consolidation via joint sourcing and 3D packaging: Simulating the interaction between warehouse stock and 3D box feasibility across millions of multi-item orders allowed us to tune our models to consolidate more items into fewer boxes—significantly reducing packaging waste, packing labor, and delivery expenses while meeting customer delivery promises.

· Refining regional proximity weighting across order profiles: Using simulation analysis of transportation costs across diverse order profiles, we enhanced how the packaging and routing workflows weight fulfillment site proximity for both single-item and multi-item shipments, ensuring shipments consistently prefer facilities closer to the customer destination.

· Dynamic multi-hop transfer optimization: Using the digital twin, we calibrated when routing an item from a remote warehouse through an internal transfer hub beats direct shipping—enabling multi-item orders to be consolidated into a single customer delivery without breaching delivery promises.

· Hourly warehouse target adherence and counterfactual inventory modeling: By simulating hourly workload targets per fulfillment site alongside counterfactual scenarios—such as evaluating theoretical network performance under unconstrained inventory or incorporating inventory lifecycle health—teams quantified the exact business impact of capacity and inventory policies before deploying them to live operations.

Future plan

As Coupang continues to expand its selection, open new fulfillment sites, and scale Rocket Delivery across global markets, our digital twin simulation platform is evolving alongside the business. We are currently investing in resumable and preemptible simulation workflows, expanding multi-day continuous simulation horizons to capture longer-term inventory rebalancing effects, and further accelerating simulation turnaround times for our global data science and engineering teams.

If solving complex, high-scale problems at the intersection of distributed systems, data science, and operations research interests you, come and check out our open positions.

While the technical content in this article reflects our company’s research activities, it does not necessarily indicate our actual investment plans or product development directions. This content is purely for research purposes and should not be used as a basis for investment decisions. Please refer to our official announcements on ir.aboutcoupang.com for information on our formal investment plans and product development strategies.

Related posts